in reply to Re^2: Date::Manip and daylight savings
in thread Date::Manip and daylight savings
I'm afraid I have to disagree here. I fail to see why 'switch to DateTime' is the correct answer.
The fact of the matter is that 1 hour before 1:00 AM on a certain date was also 1:00 AM. Date::Manip is doing it right. The reason that the information doesn't look right is that the date is only partially being printed out (i.e. no timezone information).
You could always print out the dates as timestamps (seconds since the epoch) or you could print the date in UTC time (which doesn't use daylight saving time), or there are alternate answers depending on what you're really trying to do.
As for the second question (i.e. subtract one day), the answer is a bit trickier. The problem really is 'what do you mean by 1 day ago'. If you say 'the same time the day before', that's ambiguous twice a year. When you move the clock back (as we just did), the time 1:00 AM to 2:00 AM happens twice, so if you start at 1:30 AM the day after and move back 1 day, do you mean 1:30 AM in standard time or saving time? Worse, when you move the clock forward, you bypass 1:00 AM to 2:00 AM, so if you start at 1:30 AM the following day and move back 1 day, if you specify 1:30 AM, you have an invalid date.
Date::Manip defines a day as 24 hours which DOES lead to unexpected results... but it DOES lead to unambiguous and correct results.
It would be possible to come up with another definition for '1 day'... and I'm definitely considering it (just as soon as I have a definition which is meaningful and useful)..
So, again, I'm sorry. The correct answer is NOT to switch to DateTime. The correct answer is to figure out what you really want, and then do it. I assure you that both Date::Manip and DateTime are flexible enough to do what you want.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Date::Manip and daylight savings
by BrowserUk (Patriarch) on Nov 07, 2011 at 16:02 UTC | |
|
Re^4: Date::Manip and daylight savings
by ikegami (Patriarch) on Nov 07, 2011 at 21:41 UTC | |
by Anonymous Monk on Nov 07, 2011 at 22:03 UTC | |
by ikegami (Patriarch) on Nov 07, 2011 at 22:08 UTC | |
by SBECK (Chaplain) on Nov 08, 2011 at 12:45 UTC | |
by ikegami (Patriarch) on Nov 08, 2011 at 18:04 UTC | |
| |
|
Re^4: Date::Manip and daylight savings
by ChrisDennis (Sexton) on Nov 07, 2011 at 17:28 UTC | |
by SBECK (Chaplain) on Nov 07, 2011 at 17:58 UTC | |
by ChrisDennis (Sexton) on Nov 07, 2011 at 18:34 UTC |