Ralph Bean  committed 1a9784f Merge

Merge pull request #1 from tourne/master

Show time axis in local TZ instead of UTC

  • Participants
  • Parent commits d9bc970, 1157583
  • Branches default

Comments (0)

Files changed (1)

File tw2/rrd/widgets/

 import pyrrd.rrd
+import calendar
 import datetime
 import time
 import math
         start_s = start_s / resolution * resolution
         end_s = end_s / resolution * resolution
+        # Timezone offset in seconds at start time *including* DST
+        tz_offset = start_s - calendar.timegm(cls.start.timetuple())
         labels = [item[0] for item in rrd_filenames]
         data = []
         for label, filename in rrd_filenames:
         # Coerce from seconds to milliseconds  Unix-time is in seconds.
         # *Most* javascript stuff expects milliseconds.
+        # Also subtract timezone offset in order to display the axis in local time.
         for i in range(len(data)):
-            data[i] = [(t*1000, v) for t, v in data[i]]
+            data[i] = [((t-tz_offset)*1000, v) for t, v in data[i]]
         # Wrap up the output into a list of dicts
         return [