So there's been a bunch of date math + TZ related bugs lately in
DateTime.pm, and more to be resolved.
I think the fundamental problem is that DateTime.pm is trying to cover a
few too many bases in one "simple" API.
There are a bunch of things people would like to be able to do:
- Work with just dates and do date math on them (at the level of days,
months & years). The current implementation is quite broken for this
purpose, because when you assign a non-UTC time zone to your object and do
date math, the math is done on the underlying UTC time, which causes weird
results.
- Work with local datetimes and do datetime math on them, by manipulating
the _local_ time, so that adding one hour is adding one hour to the wall
clock time.
- Work with local datetimes and do datetime math on them, but using the
underlying UTC time. This shouldn't make a difference when adding or
subtracting a duration, but it does make a differnce when determining the
interval between two datetimes.
Then there are some duration-related issues. People want to:
- Have a duration that's anchored on a given datetime, in other words a
duration as a start & end point versus ...
- Have a duration that is simply a period of time (5 hours), and is
unchanged based on the points in time.
The former could incorporate both positive and negative components (+10
days, -5 hours), while the latter never should. The current DT::Duration
object mixes these concepts together. You _can_ create one with positive
& negative components, but DateTime.pm will never give you such a thing.
I see that Sam Tregar already started on some date-related classes for
Pugs, but I don't think he's thought through a lot of this stuff, at least
based on the API he's proposing.
Anyway, I thought I'd throw this stuff out there since it might be useful
to summarize for Perl6, no matter who ends up working on its Datetime
stuff.
Also, I think we may need to consider serious backwards incompatibility in
the future of DateTime.pm (possibly via a new namespace like DateTime2) to
really clean this up, but that'll wait til I'm less tired ;)
-dave
/*===================================================
VegGuide.Org www.BookIRead.com
Your guide to all that's veg. My book blog
===================================================*/