diff --git a/lib/admin/Utils.pm b/lib/admin/Utils.pm index 5c020cf..73936b0 100644 --- a/lib/admin/Utils.pm +++ b/lib/admin/Utils.pm @@ -5,6 +5,7 @@ use warnings; use Time::Local; use HTML::Entities; use POSIX; +use DateTime::TimeZone::OffsetOnly; # Takes a search result total count, an offset and a limit and returns # an array containing offset values for a pagination link list @@ -544,9 +545,16 @@ sub addel_iplist { return 1; } -# returns the offset in localhost's timezone to GMT +=head2 tz_offset + +Returns localhost's offset to GMT in seconds + +=cut + sub tz_offset { - return strftime ("%z", localtime(time)); + use DateTime::TimeZone::OffsetOnly; + my $tz_offset = DateTime::TimeZone::OffsetOnly->new ( offset => strftime("%z", localtime(time())) ); + return $tz_offset->{offset} ; } 1; diff --git a/root/js/jsrrd/jsrrd/rrdFlot.js b/root/js/jsrrd/jsrrd/rrdFlot.js index a5ab22c..9db53eb 100644 --- a/root/js/jsrrd/jsrrd/rrdFlot.js +++ b/root/js/jsrrd/jsrrd/rrdFlot.js @@ -32,7 +32,7 @@ function rrdFlot(html_id, rrd_file, graph_options, ds_graph_options, si_suffix, else this.si_suffix = si_suffix; - // tz_offset: offset of timezone in hours + // tz_offset: offset of timezone in seconds if(tz_offset==null) this.tz_offset = 0; else @@ -187,7 +187,7 @@ rrdFlot.prototype.drawFlotGraph = function() { } ds_colors[ds_name]=i; } - + var flot_obj=rrdRRAStackFlotObj(this.rrd_file,rra_idx, ds_positive_stack_list,ds_negative_stack_list,ds_single_list, this.tz_offset); diff --git a/root/js/jsrrd/jsrrd/rrdFlotSupport.js b/root/js/jsrrd/jsrrd/rrdFlotSupport.js index f9062c0..a4e60fa 100644 --- a/root/js/jsrrd/jsrrd/rrdFlotSupport.js +++ b/root/js/jsrrd/jsrrd/rrdFlotSupport.js @@ -99,9 +99,8 @@ function rrdRRA2FlotObj(rrd_file,rra_idx,ds_list,want_ds_labels,want_rounding) { // of the stack is invalid function rrdRRAStackFlotObj(rrd_file,rra_idx, ds_positive_stack_list,ds_negative_stack_list,ds_single_list, - want_ds_labels,want_rounding,one_undefined_enough,tz_offset) - - var timestamp_shift = 3600 * tz_offset; + tz_offset, + want_ds_labels,want_rounding,one_undefined_enough) { var rra=rrd_file.getRRA(rra_idx); var rra_rows=rra.getNrRows(); @@ -117,7 +116,7 @@ function rrdRRAStackFlotObj(rrd_file,rra_idx, } var first_el=last_update-(rra_rows-1)*step; - var out_el={data:[], min:(first_el+timestamp_shift)*1000.0, max:(last_update+timestamp_shift)*1000.0}; + var out_el={data:[], min:(first_el+tz_offset)*1000.0, max:(last_update+tz_offset)*1000.0}; // first the stacks stack var stack_els=[ds_positive_stack_list,ds_negative_stack_list]; @@ -166,7 +165,7 @@ function rrdRRAStackFlotObj(rrd_file,rra_idx, } // fill the flot data for (var id=0; id