fixed timezones
authorAndrew Tridgell <tridge@samba.org>
Wed, 13 Oct 2010 22:12:28 +0000 (00:12 +0200)
committerAndrew Tridgell <tridge@samba.org>
Wed, 13 Oct 2010 22:12:28 +0000 (00:12 +0200)
live/graphs.js

index 871f8447a597b700678214fcc8c357c515f955fe..d2317e0510dfe90759c7ebcf932a301e07fa59d3 100644 (file)
@@ -52,17 +52,15 @@ function date_round(d) {
  */
 function canberraDate() {
   var d = new Date();
-  var tz = -d.getTimezoneOffset()/60;
-  var diff = tz - 11;
-  writeDebug("tz=" + tz + " diff=" + diff);
-  d.setHours(d.getHours() + diff);
-  return d;
+  return date_round(new Date(d.getTime() + (tz_difference*60*60*1000)));
 }
 
 /*
-  setup midnight as a date
+  work out timezone
  */
 pvdate = new Date();
+tz_difference = 11 + (pvdate.getTimezoneOffset()/60);
+
 
 
 /* marker for whether we are in a redraw with new data */
@@ -515,7 +513,7 @@ function load_annotations(g) {
     var anns_by_name = new Array();
     annotations = [];
     for (var i=0; i<d.data.length; i++) {
-      var xval = d.data[i][0];
+      var xval = d.data[i][0] + (tz_difference*60*60*1000);
       if (xval < pvdate.valueOf() || xval >= (pvdate.valueOf() + (24*60*60*1000))) {
        continue;
       }