[Git][NTPsec/ntpsec][master] Clip ntpdig reports according to resonse precision field.
Eric S. Raymond
gitlab at mg.gitlab.com
Thu Nov 24 04:21:32 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
190ee039 by Eric S. Raymond at 2016-11-23T23:20:49-05:00
Clip ntpdig reports according to resonse precision field.
- - - - -
2 changed files:
- ntpdig/pyntpdig
- pylib/packet.py
Changes:
=====================================
ntpdig/pyntpdig
=====================================
--- a/ntpdig/pyntpdig
+++ b/ntpdig/pyntpdig
@@ -190,8 +190,18 @@ def report(packet, json, adjusted):
t = time.localtime(int(packet.transmit_timestamp))
ms = int(packet.transmit_timestamp * 1000000) % 1000000
+ digits = 0
+ precision = packet.precision
+ while True:
+ precision *= 10.0
+ if precision >= 1:
+ break
+ digits += 1
+ if digits > 6:
+ digits = 6;
+
date = time.strftime("%Y-%m-%d", t)
- tod = time.strftime("%T", t) + (".%d" % ms)
+ tod = time.strftime("%T", t) + (".%*d" % (digits, ms))
sgn = ("%+d" % tmoffset)[0]
tz = "%s%02d%02d" % (sgn, tmoffset // 60, tmoffset % 60)
=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -364,7 +364,6 @@ class SyncPacket(Packet):
return abs(self.delta() - self.epsilon())
def adjust(self):
"Adjustment implied by this packet."
- # FIXME: Clip low digits according to precision
return self.received - self.transmit_timestamp
def leap(self):
return ("no-leap", "add-leap", "del-leap", "unsync")[((self.li_vn_mode) >> 6) & 0x3]
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/190ee039df6230c12d459bac73a1d75e99455ebd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161124/8a45445f/attachment.html>
More information about the vc
mailing list