|Problems? Is your data what you think it is?|
Re^9: Date::Manip and daylight savingsby SBECK (Friar)
|on Nov 08, 2011 at 18:44 UTC||Need Help??|
I'm not avoiding answering the question. I thought I DID answer the question. I'll try again... but please remain civil in your reply or I'll probably drop out of this conversation.
Can Date::Manip add a year or only 365 days? I clearly stated that Date::Manip would add a year the same as TimeDate. So yes, Date::Manip can add either a year OR 365 days. The results are identical for Date::Manip and TimeDate except for the case that I cited (i.e. starting on Feb 29 on a leap year) so 2007-11-07 plus one year is 2008-11-07. The two modules differ only in the case of leap year.
Actually, a year of a date is quite well defined. In 2011-11-08, 2011 is the year.
True, but not relevant to the discussion. We're discussing an amount of time. The actual date is irrelevant except for the fact that the date does impacts how we think of the amount of time. That's why this is all so hard... the amount of time is not defined in a mathematical way, it's defined in a human-perspective way which is definitely not simple to enumerate. The example of adding a year is a simple example though. What does it mean to add a year to 2004-02-29. The answer is obviously not to add 365 or 366 days, and the answer is NOT just to modify the year field, because then you'd end up with 2005-02-29 which is not valid, so adding an amount of time is not a simple operation.
It appears that the operation to add a year to a date for DateTime is as follows. Increment the year. If the resulting date is invalid (which only happens in the case of leap years), move forward the number of days you're off by. This is supported by the fact that Jan 31 + 1 month = Mar 3.
The operation used by Date::Manip is different. Increment the year. If the resulting date is invalid, drop back to the last valid date. The advantage is that the month is preserved (you can basically think that I went from the last day in February 2004 to the last day in February 2005). In a similar fashion, Jan 31 plus 1 month is Feb 28 (or 29).
So Date::Manip can add years, months, weeks, hours, minutes, and seconds in a similar (though not identical) fashion as DateTime. Days is the only one where we differ significantly, and I'm working on that now (I'd been intending to add this... and this discussion has pushed this to the forefront). However, here too, the results won't be the same because I'll use a operation (for example, it won't ever return an empty date).
I'll be happy to clarify any points that are not clear.