Dave Rolsky schreef:
> On Wed, 26 Feb 2003, Eugene van der Pijll wrote:
> > When converting DateTime -> DateTime, 'utc' makes more sense, as the utc
> > rata die and seconds are used. In general, 'floating' could be better,
> > as some calendars may not implement timezones, and _utc_rd_values
> > returns 'floating' time values.
>
> Hmm, good point. Maybe something like:
>
> my $tz = $object->can('time_zone') ? 'UTC' : 'floating;
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.
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.
> > $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.
2. All datetimes are local if the time is given; if no 'hour' parameter
is given to new() the datetime is floating.
3. All datetimes are local; if Eugene wants to use only the date part of
a datetime, he can write his own module.
Option 1 is perhaps the best; but also the most difficult to implement;
option 2 is probably impossible if you want to use Params::Validate;
option 3 is not my favorite.
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.
Eugene