Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 56389
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: michal.svoboda [...] agents.felk.cvut.cz
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.56



Subject: floating timezones are either buggy or poorly documented
Date: Thu, 8 Apr 2010 15:07:24 +0200
To: bug-DateTime [...] rt.cpan.org
From: Michal Svoboda <michal.svoboda [...] agents.felk.cvut.cz>
It seems that DateTime->now(time_zone => 'floating') constructs a datetime object in the UTC timezone. For example ->hms reports time minus the localtimezone offset. Now, from all the available documentation it seems that 'floating' is NOT UTC and should be used 'when you dont care about the timezone', which is my case. I would thus expect the object to reflect LOCAL time with the added benefit that '-1 day' works across DST changes (because the timzeone is 'floating'). If this is not the case then please explain (also in the POD) how _exactly_ floating functions and better yet how to achieve the -1 day thingy. (I really don't care if its 02 or 03 o'clock, I just want to know what date it was yesterday, 7 weeks ago, and so on.)
Download (untitled)
application/pgp-signature 198b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #56389] floating timezones are either buggy or poorly documented
Date: Thu, 8 Apr 2010 08:13:27 -0500 (CDT)
To: Michal Svoboda via RT <bug-DateTime [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Thu, 8 Apr 2010, Michal Svoboda via RT wrote: Show quoted text
> Now, from all the available documentation it seems that 'floating' is > NOT UTC and should be used 'when you dont care about the timezone', > which is my case. I would thus expect the object to reflect LOCAL time > with the added benefit that '-1 day' works across DST changes (because > the timzeone is 'floating'). > > If this is not the case then please explain (also in the POD) how > _exactly_ floating functions and better yet how to achieve the -1 day > thingy. (I really don't care if its 02 or 03 o'clock, I just want to > know what date it was yesterday, 7 weeks ago, and so on.)
Doc patches are welcome. The issue here is that ->now constructs an object in the UTC zone and _then_ sets the time zone to the one you provided. When you go from any time zone to floating, the time zone stays the same. Sounds like you might want something like ... DateTime->now( time_zone => 'local' )->set_time_zone( 'floating' ); -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
Subject: Re: [rt.cpan.org #56389] floating timezones are either buggy or poorly documented
Date: Thu, 8 Apr 2010 16:01:02 +0200
To: "autarch [...] urth.org via RT" <bug-DateTime [...] rt.cpan.org>
From: Michal Svoboda <michal.svoboda [...] agents.felk.cvut.cz>
autarch@urth.org via RT wrote: Show quoted text
> Doc patches are welcome. > > The issue here is that ->now constructs an object in the UTC zone and > _then_ sets the time zone to the one you provided. When you go from any > time zone to floating, the time zone stays the same. > > Sounds like you might want something like ... > > DateTime->now( time_zone => 'local' )->set_time_zone( 'floating' );
That seems to work. Thus I suggest --- DateTime.pm.old 2010-04-08 15:48:48.924354647 +0200 +++ DateTime.pm 2010-04-08 15:56:25.900979340 +0200 @@ -3077,11 +3077,25 @@ If you do not care about time zones or leap seconds, use the "floating" timezone: - my $dt = DateTime->now( time_zone => 'floating' ); + my $dt = DateTime->now( time_zone => 'local' ) + ->set_time_zone( 'floating' ); Math done on two objects in the floating time zone produces very predictable results. +Note that in most cases you want to first set up the DateTime object in +the local time zone and then "strip" time zone information by setting +the time zone to floating. The use of + + my $dt = DateTime->now( time_zone => 'floating' ); + +is equivalent to + + my $dt = DateTime->now( time_zone => 'UTC' ) + ->set_time_zone( 'floating' ); + +which might not be what you want. + =item * use UTC for all calculations If you do care about time zones (particularly DST) or leap seconds,
Download (untitled)
application/pgp-signature 198b

Message body not shown because it is not plain text.