in reply to Re^5: Date::Manip and daylight savings
in thread Date::Manip and daylight savings
you will produce an invalid local time, and therefore an exception will be thrown.
As it should. Returning an invalid local time (2003-04-06T02:00:00) would be wrong.
Are you implying that Date::Manip behaves differently?
Just convert your datetime object to the "UTC" time zone before doing date math on it, and switch it back to the local time zone afterwards.
That's bad advice. It's just a very expensive way of doing $dt->add( hours => 24 );, which is very different than adding a day.
use feature qw( say );; use DateTime; my $dt = DateTime->new( year => 2003, month => 4, day => 5, hour => 2, time_zone => 'America/Chicago', ); $dt->set_time_zone('UTC'); $dt->add( days => 1 ); $dt->set_time_zone('America/Chicago'); say $dt; # ERROR: 2003-04-06T03:00:00
My question went unanswered. Is Date::Manip only able to add 24 hours, or is it also able to add one day?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Date::Manip and daylight savings
by SBECK (Chaplain) on Nov 08, 2011 at 12:45 UTC | |
by ikegami (Patriarch) on Nov 08, 2011 at 18:04 UTC | |
by SBECK (Chaplain) on Nov 08, 2011 at 18:44 UTC | |
by ikegami (Patriarch) on Nov 08, 2011 at 19:49 UTC | |
by BrowserUk (Patriarch) on Nov 08, 2011 at 18:30 UTC | |
by Anonymous Monk on Nov 08, 2011 at 18:48 UTC | |
by ikegami (Patriarch) on Nov 08, 2011 at 19:48 UTC |