NAME
simple time sequence base on Date::Calc
FUNCTION
get_time
my $lastday_this_hour = get_time(
undef,
format => "%04d-%02d-%02d %02d",
delta => { day => -1 },
);
print $lastday_this_hour, "\n";
#2014-06-10 14
my $time_10min_before = get_time(
"2014-06-10 22:22:22",
delta => {
year => 0,
month => 0,
day => 0,
hour => 0,
minute => -10,
second => 0,
},
);
# 2014-06-10 22:12:22
seq_times
my $seq = seq_times(
"2014-06-11 07:15:22", "2014-06-11 12:00:00",
delta => { minute => 30 },
format => "%04d-%02d-%02d %02d:%02d",
trim_end => 0,
);
print "$_\n" for @$seq;
#2014-06-11 07:15
#2014-06-11 07:45
#2014-06-11 08:15
#2014-06-11 08:45
#2014-06-11 09:15
#2014-06-11 09:45
#2014-06-11 10:15
#2014-06-11 10:45
#2014-06-11 11:15
#2014-06-11 11:45
#2014-06-11 12:00
cut_time
my $c = cut_time( "2014-06-11 09:33", $seq );
print $c, "\n";
#2014-06-11 09:15