in reply to Re: Check if Date interval contains Hour X
in thread Check if Date interval contains Hour X
Another (maybe simpler) way of truncating:
sub hour_in_range { my ($dt_s, $dt_e, @hours) = @_; for my $hour (@hours) { my $dt = $dt_s->clone() ->truncate( to => 'day' ) ->add( hours => $hour ); $dt->add( days => 1 ) if $dt < $dt_s; return 1 if $dt <= $dt_e; } return 0; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Check if Date interval contains Hour X
by ikegami (Patriarch) on Jul 23, 2009 at 21:50 UTC | |
by alexm (Chaplain) on Jul 23, 2009 at 22:41 UTC |
In Section
Seekers of Perl Wisdom