summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-12-29 13:32:35 +0000
committerLars Wirzenius <liw@liw.fi>2011-12-29 13:32:35 +0000
commit0bb1c8aab4c7ca7ed66ab756d10131691a4f235e (patch)
treee09239e2c270a4479b4ac4385046834b263e3461
parent1f68a394826daabe18c5662ba60c583450cdb72d (diff)
downloadsummain-0bb1c8aab4c7ca7ed66ab756d10131691a4f235e.tar.gz
produce nanosec timestamps without floating point
Go away, stupid rounding error, away!
-rw-r--r--summainlib.py2
-rw-r--r--summainlib_tests.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/summainlib.py b/summainlib.py
index 8eac369..79e64e7 100644
--- a/summainlib.py
+++ b/summainlib.py
@@ -211,7 +211,7 @@ class FilesystemObject(object):
def format_time(self, secs, nsecs):
s = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(secs))
- s += ('%.6f' % (nsecs * 1e-9))[1:] # skip leading 0
+ s += '.%09d' % nsecs
s += ' +0000'
return s
diff --git a/summainlib_tests.py b/summainlib_tests.py
index 8480057..f8bcc27 100644
--- a/summainlib_tests.py
+++ b/summainlib_tests.py
@@ -109,7 +109,7 @@ class FilesystemObjectTests(unittest.TestCase):
def test_formats_mtime_correctly(self):
self.assertEqual(self.new('foo')['Mtime'],
- '2010-01-01 01:02:03.123457 +0000')
+ '2010-01-01 01:02:03.123456789 +0000')
def test_formats_mode_for_regular_file_correctly(self):
self.assertEqual(self.new('foo')['Mode'], '100644')