Skip to content

Commit

Permalink
Merge pull request #37 from zopefoundation/pyts-timetime
Browse files Browse the repository at this point in the history
TimeStamp: sub-second precision for Python implementation of timeTime()
  • Loading branch information
jimfulton committed May 5, 2016
2 parents aea7889 + c98aad1 commit 5b2a7f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion persistent/tests/test_timestamp.py
Expand Up @@ -100,9 +100,10 @@ def test_ctor_from_string(self):
self.assertEqual(ts.timeTime(), DELTA_SECS)

def test_ctor_from_string_non_zero(self):
before = self._makeOne(2011, 2, 16, 14, 37, 22.0)
before = self._makeOne(2011, 2, 16, 14, 37, 22.80544)
after = self._makeOne(before.raw())
self.assertEqual(before.raw(), after.raw())
self.assertEqual(before.timeTime(), 1297867042.80544)

def test_ctor_from_elements(self):
from persistent.timestamp import _makeOctets
Expand Down
2 changes: 1 addition & 1 deletion persistent/timestamp.py
Expand Up @@ -119,7 +119,7 @@ def timeTime(self):
""" -> seconds since epoch, as a float.
"""
delta = _makeUTC(*self._elements) - _EPOCH
return delta.days * 86400.0 + delta.seconds
return delta.days * 86400 + delta.seconds + delta.microseconds / 1e6

def laterThan(self, other):
""" Return a timestamp instance which is later than 'other'.
Expand Down

0 comments on commit 5b2a7f5

Please sign in to comment.