Anonymous committed 1157583

Subtract local timezone offset from time axis timestamps, in order to show local time instead of UTC in js widgets.

Comments (0)

Files changed (1)


 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 [