[Git][NTPsec/ntpsec][master] Fixed error in posix_to_ntp: it recieves floats so it can't shift
Ian Bruene
gitlab at mg.gitlab.com
Wed Aug 23 20:13:36 UTC 2017
Ian Bruene pushed to branch master at NTPsec / ntpsec
Commits:
bc4c6cf2 by Ian Bruene at 2017-08-23T15:12:44-05:00
Fixed error in posix_to_ntp: it recieves floats so it can't shift
- - - - -
2 changed files:
- pylib/packet.py
- tests/pylib/test_packet.py
Changes:
=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -460,7 +460,8 @@ class SyncPacket(Packet):
def posix_to_ntp(t):
"Scale from POSIX time to NTP time"
# Note: assumes we're in the same NTP era as the transmitter...
- return int((t + SyncPacket.UNIX_EPOCH) << 32)
+ # This recieves floats, can't use shifts
+ return int((t + SyncPacket.UNIX_EPOCH) * 2**32)
def posixize(self):
"Rescale all timestamps to POSIX time."
=====================================
tests/pylib/test_packet.py
=====================================
--- a/tests/pylib/test_packet.py
+++ b/tests/pylib/test_packet.py
@@ -427,7 +427,7 @@ class TestSyncPacket(unittest.TestCase):
def test_ntp_to_posix(self):
f = self.target.ntp_to_posix
# Test the Timeless Void Before Existence
- self.assertEqual(f(-1), -2208988800) # NTP can't see the Timeless Void
+ self.assertEqual(f(-1), -2208988801) # NTP can see the Timeless Void
# Test beginning of NTP epoch
self.assertEqual(f(0), -2208988800)
# Test just before the Age of Unix
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/bc4c6cf24958aac9af581698bd86d6f4d3c84db1
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/bc4c6cf24958aac9af581698bd86d6f4d3c84db1
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170823/5a230d46/attachment.html>
More information about the vc
mailing list