Subject: | Fwd: DateTime |
Date: | Wed, 20 Oct 2010 15:57:54 +0200 |
To: | bug-datetime [...] rt.cpan.org |
From: | Reiner Rusch <reiner.rusch [...] idealo.de> |
Hello,
perhaps a bug?
Best regards,
Reiner Rusch
Subject: | DateTime |
Date: | Wed, 20 Oct 2010 12:24:11 +0200 |
To: | autarch [...] urth.org |
From: | Reiner Rusch <reiner.rusch [...] idealo.de> |
Hello Mr. Rolsky,
I had some trouble with DateTime a view days ago.
Doing something like
$dt = DateTime->from_epoch(epoch => int($unixTime));
Other functions/scripts outsite this function sometimes breaked with something
like
#############################
Use of uninitialized value in string
at /usr/angebote/perlroot/lib/site_perl/5.8.6/x86_64-linux/DateTime.pm line
1833, <GEN5> line 667.
#############################
By know I don't know exactly, which data curses this.
But I made a workaround in DateTime.pm (above line 1833):
old:
#############################
sub _string_equals_overload {
my ( $class, $dt1, $dt2 ) = ref $_[0] ? ( undef, @_ ) : @_;
if ( !DateTime::Helpers::can( $dt2, 'utc_rd_values' ) ) {
return "$dt1" eq "$dt2";
}
$class ||= ref $dt1;
return !$class->compare( $dt1, $dt2 );
}
#############################
new:
#############################
sub _string_equals_overload {
my ( $class, $dt1, $dt2 ) = ref $_[0] ? ( undef, @_ ) : @_;
if ( !DateTime::Helpers::can( $dt2, 'utc_rd_values' ) ) {
# Hack/Workaround by R.Rusch, 19.10.2010
if (not defined $dt1) {
$dt1 = '';
}
if (not defined $dt2) {
$dt2 = '';
}
# Hack/Workaround by R.Rusch, 19.10.2010
return "$dt1" eq "$dt2";
}
$class ||= ref $dt1;
return !$class->compare( $dt1, $dt2 );
}
#############################
Best regards from Berlin,
R.Rusch