Commit 5b2a7f57 authored by Jim Fulton's avatar Jim Fulton

Merge pull request #37 from zopefoundation/pyts-timetime

TimeStamp: sub-second precision for Python implementation of timeTime()
parents aea7889c c98aad18
...@@ -100,9 +100,10 @@ class pyTimeStampTests(unittest.TestCase): ...@@ -100,9 +100,10 @@ class pyTimeStampTests(unittest.TestCase):
self.assertEqual(ts.timeTime(), DELTA_SECS) self.assertEqual(ts.timeTime(), DELTA_SECS)
def test_ctor_from_string_non_zero(self): 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()) after = self._makeOne(before.raw())
self.assertEqual(before.raw(), after.raw()) self.assertEqual(before.raw(), after.raw())
self.assertEqual(before.timeTime(), 1297867042.80544)
def test_ctor_from_elements(self): def test_ctor_from_elements(self):
from persistent.timestamp import _makeOctets from persistent.timestamp import _makeOctets
......
...@@ -119,7 +119,7 @@ class pyTimeStamp(object): ...@@ -119,7 +119,7 @@ class pyTimeStamp(object):
""" -> seconds since epoch, as a float. """ -> seconds since epoch, as a float.
""" """
delta = _makeUTC(*self._elements) - _EPOCH 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): def laterThan(self, other):
""" Return a timestamp instance which is later than 'other'. """ Return a timestamp instance which is later than 'other'.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment