So I have it to a state where I'm pretty happy with the code and docs. It
won't satisfy everyone, but that's more or less impossible given how many
"correct" ways of doing datetime math I've come up with.
Here's the summary:
- Adding a duration contains to work the same way as it always did, adding
calendar bits (months & days) to the local date, and time bits to the utc
time. This generally just works as people expect and I haven't heard many
complaints about it.
- The subtract_datetime() method now does all its math on the UTC
representation of the datetimes (unless they're floating). This is the
sanest solution I could think of given the fact that any unit has to be
convertible to any other unit to get a reasonable result (cause if you
subtract hour 23 from hour 0, you pull a day off the object with hour 23).
This means that if you do subtract_datetime on two objects you end up with
this situation:
$dur = $dt2 - $dt1
$dt1 + $dur != $dt2
$dt2 - $dur != $dt1
But honestly I don't really think that's a bug, and it's covered in the
docs.
- I updated the docs quite a bit to try to cover all the weird cases,
particularly the ones that occur when you do math on an object in a
DST-using time zone.
I tested the new version with all the Calendar & Event modules in the DT
CVS repo, and they all passed. However, DateTime::Format::Duration from
CPAN does not pass.
-dave
/*===================================================
VegGuide.Org www.BookIRead.com
Your guide to all that's veg. My book blog
===================================================*/