]> git.proxmox.com Git - pmg-api.git/commitdiff
round timespan to integer
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 12 Sep 2017 06:06:49 +0000 (08:06 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 12 Sep 2017 06:06:49 +0000 (08:06 +0200)
old code was a NOP, because it uses float.

PMG/Statistic.pm

index 62574950dd3eb72f9bf8d71955308d9090219da5..2698a3fcbcdffa9a3873f8c3fc0311c365a0fdaf 100755 (executable)
@@ -880,8 +880,8 @@ sub localdayspan {
     my ($from, $to) = $self->timespan();
 
     my $timezone = tz_local_offset();;
-    $from = (($from + $timezone)/86400) * 86400;
-    $to = (($to + $timezone)/86400) * 86400;
+    $from = int(($from + $timezone)/86400) * 86400;
+    $to = int(($to + $timezone)/86400) * 86400;
 
     $to += 86400 if $from == $to;
 
@@ -894,8 +894,8 @@ sub localhourspan {
     my ($from, $to) = $self->timespan();
 
     my $timezone = tz_local_offset();;
-    $from = (($from + $timezone)/3600) * 3600;
-    $to = (($to + $timezone)/3600) * 3600;
+    $from = int(($from + $timezone)/3600) * 3600;
+    $to = int(($to + $timezone)/3600) * 3600;
 
     $to += 3600 if $from == $to;