diff --git a/TimeSeries.pm b/TimeSeries.pm index 39edd64..753ee04 100644 --- a/TimeSeries.pm +++ b/TimeSeries.pm @@ -33,7 +33,7 @@ use HTTP::Date qw(parse_date); use Time::Local qw(timegm_nocheck); use POSIX qw(strftime); -our $VERSION = do { my @r=(q$Revision: 1.17 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r}; +our $VERSION = do { my @r=(q$Revision: 1.18 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r}; =head2 new(%opts) @@ -513,10 +513,17 @@ sub get_ticks { $label = '%Y-%m-%d %H:%M'; $nexttime = sub { return $_[0] + 3600 }; + } elsif ($lasttime - $firsttime > 1 * 3600) { + # 1 to 6 hours: 1 tick per 15 minutes. + + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime); + $sec = 0; + $min = int($min / 15) * 15; + $firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year); + $label = '%Y-%m-%d %H:%M'; + $nexttime = sub { return $_[0] + 15 * 60 }; } else { - # less than 6 hours: 1 tick per minute. - # (ok, that's too much - need to find some intermediate steps, - # but for now I need graphs over a few minutes. + # less than 1 hour: 1 tick per minute. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime); $sec = 0;