[Git][NTPsec/ntpsec][master] Fix issue #176, start/end time are not really UTC.

Gary E. Miller gitlab at mg.gitlab.com
Fri Dec 2 02:35:17 UTC 2016


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
c87b6356 by Gary E. Miller at 2016-12-01T18:34:54-08:00
Fix issue #176, start/end time are not really UTC.

Issue #176:
"ntpviz generated index.html Start Time and End Time -- are not really
UTC though labeled as such."

- - - - -


2 changed files:

- ntpstats/ntpviz
- pylib/statfiles.py


Changes:

=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -1505,9 +1505,9 @@ dd {
 
     # Ugh.  Not clear what to do in the multiplot case
     if len(statlist) == 1:
-        start_time = datetime.datetime.fromtimestamp( stats.starttime
+        start_time = datetime.datetime.utcfromtimestamp( stats.starttime
                          ).strftime('%c')
-        end_time = datetime.datetime.fromtimestamp( stats.endtime
+        end_time = datetime.datetime.utcfromtimestamp( stats.endtime
                          ).strftime('%c')
 
         index_header += '<b>Start Time:</b> %s UTC<br>\n' \


=====================================
pylib/statfiles.py
=====================================
--- a/pylib/statfiles.py
+++ b/pylib/statfiles.py
@@ -202,11 +202,14 @@ class NTPStats:
         return key      # Someday, be smarter than this.
 
 def iso_to_posix(s):
-    "Accept timestamps in ISO8661 format or numeric POSIX time."
+    "Accept timestamps in ISO8661 format or numeric POSIX time. UTC only."
     if s.isdigit():
         return int(s)
     else:
-        return time.mktime(time.strptime(s, "%Y-%m-%dT%H:%M:%S"))
+        t = time.strptime(s, "%Y-%m-%dT%H:%M:%S")
+        t.m_isdst = 0
+        # don't use time.mktime() as taht is local tz
+        return  calendar.timegm(t)
 
 def posix_to_iso(t):
     "ISO8601 string from Unix time."



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/c87b635688ec8d0b6ff0cf2dbdad9d4893bfd987
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161202/5f39f84b/attachment.html>


More information about the vc mailing list