Re: How to correctly add a duration to not have it result in invalid date?
[email protected] (Thomas Klausner)
| Newsgroups | perl.datetime |
|---|---|
| Message-ID | <[email protected]> |
Hi!
On Thu, Mar 07, 2013 at 08:34:47PM -0800, Bill Moseley wrote:
> Invalid local time for date in time zone: America/Los_Angeles
I've had the same problem several times in the past (mostly in
America/Sao_Paulo, which has the very stupid idea of making the switch
to winter time at 0:00 (so there is no 00:00:00 - 00:59:59 on that
day)).
You can probably find the discussion in the archive. I suggested some
fixes/workarounds, but they were rejected for being not correct. (They
are not correct in a very technical sense, but would be extremly
practical, IMO).
> What would happen if duration calculations were always done in UTC?
This is the correct (albeit complex) solution. Always do date math in
UTC, and convert back to local time zone later. I find this solution not
very practical or perlish, but other solutions probably won't be
accepted into DateTime (or weren't when I tried the last time...)
Greetings,
domm
--
#!/usr/bin/perl http://domm.plix.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}