Subject: | Date calculation can return invalid time |
In the Europe/Athens timezone, date 2014-03-30 03:30:00 is non-existent, is invalid, because the time jumped then from 03:00:00 directly to 04:00:00.
However the following much-used date calculation leads to such an invalid date and causes the program to badly crash.
#!/usr/bin/perl
use strict;
use warnings;
use DateTime;
my $dt = DateTime->new(
year => 2014,
month => 3,
day => 29,
hour => 3,
minute => 30,
second => 0,
time_zone => 'Europe/Athens',
);
print $dt, "\n";
print $dt->add(days => 1), "\t";
__END__
That means, that whoever tried to log on to my site on the 29th around 3:30, couldn't access the site.