On Fri, 7 Feb 2003, Rick Measham wrote:
> A while back Dave asked us about timezones and should setting a timezone
> move the internal representation or the external. We all agreed on the
> external. Mainly because we couldn't think of a use for internal. Well, for
> the first time ever, I'm using DateTime and I need to change the INTERNAL!
> LOL!
>
> What I'm trying to work out is the time difference a particular timezone is.
>
> The following is how I figured I'd do this:
> $rth = DateTime->now;
> $here = $rth->clone;
> $rth->set_time_zone('Australia/Melbourne');
> $diff = $rth-$here;
>
> However that doesn't work because the internal stays exactly the same! The
> Diff returns 0!
>
> Now maybe we need $rth->move_internal_timezone('Australia/Melbourne');
>
> Or I need to figure some other way of doing this. (Any help on a workaround
> would be great)
The awkward workaround is this:
my $here = DateTime->new( time_zone => 'Australia/Melbourne',
map { $_ => $rth->$_() }
qw( year month day hour minute second ) );
That should do what you want, which is create two datetime objects with
the same _local_ time, and different time zones.
A more elegant way of expressing this idiom is welcome ;)
-dave
/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/