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: 9278
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: DROLSKY [...] cpan.org
Requestors: t_cpan [...] fictive.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.22
Fixed in: 0.25



Subject: from_object constructs object in "floating" time zone, not UTC as documented
in v0.22, the from_object method puts the constructed object in the "floating" time zone, not in UTC as documented. The example (use attached RataDie.pm) prints: 2003-08-31 07:00:00 floating instead of 2003-08-31 07:00:00 UTC adding a 'time_zone' method to the RataDie class solves the issue, but is not consistent with the documentation, which states explicitly: "If the object passed to this method has a time_zone() method, that is used to set the time zone of the newly created DateTime.pm object. Otherwise UTC is used." i am on a debian machine with libdatetime-perl-0.22-1 installed. ----------------------------------------------------------------------- #!/usr/bin/perl -w use strict; use DateTime; use RataDie; my $rd = RataDie->new("63197996400"); my $dt = DateTime->from_object(object => $rd); print $dt->strftime("%F %T %Z\n"); # EOF
#!/usr/bin/perl -w package RataDie; sub new { my ($class, $rd) = @_; my $days = int($rd / 86400); my $secs = $rd - ($days * 86400); my $self = {utc_rd_days => $days, utc_rd_secs => $secs}; bless $self, $class; } sub utc_rd_values { @{$_[0]}{'utc_rd_days', 'utc_rd_secs'}; } 1; # # EOF
I've changed the docs, since I don't want to risk breaking existing code.
BTW: thanks a million for this great class! -t