Subject: | format_datetime returns undef when time_zone is set |
DateTime::Format::W3CDTF->format_datetime (0.3) returns undef when you pass it a DateTime object whose timezone has been explicitly set.
I fixed this by passing the return value of the DateTime object's 'offset' value to the internal 'offset_to_string' function, rather than passing the TimeZone's 'offset' set key.
A patch is attached.
--- ./W3CDTF.pm.dist Mon Mar 10 12:50:05 2003
+++ ./W3CDTF.pm Wed Sep 10 23:26:20 2003
@@ -95,8 +95,8 @@
if ( $dt->hour || $dt->min || $dt->sec ) {
return $base . 'Z' if $tz->is_utc;
- if ( $tz->{'offset'} ) {
- return $base . offset_as_string( $tz->{'offset'} );
+ if (my $offset = $dt->offset()) {
+ return $base . offset_as_string($offset );
}
}
else {