Monks,
I'm doing a simple reservation system and using DateTime I can make sure the reservation is not before today.
use DateTime;
my $now = DateTime->now( time_zone => 'Pacific/Honolulu' );
my $reservation_date = DateTime->new(
year => $CONFIG{'date_year'},
month => $CONFIG{'date_month'},
day => $CONFIG{'date_day'},
hour => $myhour,
minute => $mymin,
time_zone => 'Pacific/Honolulu',
);
if ($reservation_date < $now) {
print "error";
}
But what I need now is to restrict future reservations to no more than 1 week ahead of time, but something like this doesn't work:
} elsif ($reservation_date - $now > 7) {
do something.
}
It seems I have to use the duration compare class, but I'm not sure how to do it when I'm only comparing the reservation date to now, and the base time to compare to is now.