On Wed, 26 Feb 2003, Eugene van der Pijll wrote:
> If $object->can('time_zone'), the _utc_rd_values should be interpreted
> as 'utc', but you can just take the $object->timezone (and clone it?)
> and use that.
True. Time zone objects are actually singletons, so no need to clone
anything.
> Of course, this assumes that all modules that have a time_zone() method
> use the same time zones. For clocks with different hours and minutes,
> like the French revolutionary clock, this might not be the case... On
> the other hand, they didn't really have time zones then.
If anyone knows of another time zone system, I'd like to hear about it (or
maybe not, I don't need more headaches ;)
> > > $d = DateTime->new( year => 2002, month => 10, day => 24 );
> > > $d += DateTime::Duration->new( weeks => 1 );
> > > print $d->ymd, "\n";
> > >
> > > This prints 2002-10-30...
> >
> > That's a good argument.
>
> There are of course other solutions:
>
> 0. All datetimes are floating (or utc) unless a timezone is given.
>
> 1. Remove the default values for hour/minute/second; if no times are
> given, these values are undef, and no time calculations (including TZ
> and DST) are done.
These two are actually more or less the same. If an object's TZ if
floating or UTC, then adding days/weeks/months/years should never change
the time.
> 2. All datetimes are local if the time is given; if no 'hour' parameter
> is given to new() the datetime is floating.
Too magical ;)
> 3. All datetimes are local; if Eugene wants to use only the date part of
> a datetime, he can write his own module.
Nah, too many similar modules ;)
I don't think there's any reason this module can't do both complicated
time zone stuff _and_ simple date-only math. Certainly with the floating
or UTC time zones available, this is possible.
I'm not particularly wedded to defaulting to "local" as the time zone
really. I was just doing what Date::ICal did for lack of a better
suggestion. It seems to me that default to floating or UTC might be a lot
more straightforward. If you want to the time zone calculations as well,
it's easy enough to get.
So does anybody reading this object to me changing the default time zone
to UTC? I think UTC is better than floating here simply because it's
easier to explain.
> Oh, I forgot one: datetime assumes that adding 1 day is the same as
> adding 24 hours:
>
> print $d = DateTime->new( year => 2002,
> month => 10,
> day => 27,
> time_zone => 'Europe/Amsterdam' ),
> "\n",
> $d += DateTime::Duration->new( days => 1 ),
> "\n";
>
> Sun, 27 Oct 2002 00:00:00 CEST
> Sun, 27 Oct 2002 23:00:00 CET
>
> Is this correct? I would say no, but I know that there are those who
> disagree.
This has to do with the internal implementation, which is to add things to
the UTC Rata Die days and seconds values, and then re-calculate the local
time. If someone adds hours, minutes, or seconds explcitly, this is
definitely the right approach. But if they add days or months, it's not
clear which is correct. It might be better to add it to the local time
and re-calculate UTC.
What do others think?
-dave
/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/