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