Subject: | format_timestamp_with_timezone, parse_timestamp_with_timezone : missing from 0.06 due to (?)typo |
Date: | Wed, 24 Jun 2015 16:38:31 +0100 |
To: | bug-DateTime-Format-Oracle [...] rt.cpan.org |
From: | Matthew Astley <mca [...] sanger.ac.uk> |
Hi,
Thanks for DateTime::Format::Oracle.
I was trying to use
DateTime::Format::Oracle 0.06
DBIx::Class::InflateColumn::DateTime from DBIx::Class 0.08250
Oracle 11g 11.2.0.4.0
and found that "timestamp with timezone" was losing the timezone,
giving me a 3600 second time offset.
This is because D:C:IC::DateTime is constructing[1] methods named =~
/_timestamp_with_timezone$/ and the implemented methods are =~
/_timestamp_with_time_zone$/
I fixed this in my application with symbol table aliases,
use DateTime::Format::Oracle 0.06; # for parse_timestamp_with_timezone
(* DateTime::Format::Oracle::parse_timestamp_with_timezone =
\&DateTime::Format::Oracle::parse_timestamp_with_time_zone ) unless
DateTime::Format::Oracle->can('parse_timestamp_with_timezone');
(* DateTime::Format::Oracle::format_timestamp_with_timezone =
\&DateTime::Format::Oracle::format_timestamp_with_time_zone ) unless
DateTime::Format::Oracle->can('format_timestamp_with_timezone');
Sorry, I can't think of a good way to write a test this without
bringing in DBIx::Class and an Oracle instance.
--
Matthew
[1] debug output
preferred_method = format_timestamp_with_timezone; DateTime::Format::Oracle 0.06 from /software/perl-5.16.2/lib/site_perl/5.16.2/DateTime/Format/Oracle.pm CANNOT
preferred_method = parse_timestamp_with_timezone; DateTime::Format::Oracle 0.06 from /software/perl-5.16.2/lib/site_perl/5.16.2/DateTime/Format/Oracle.pm CANNOT
inflate(began) 2015-06-24 14:40:52 +0100,Sanger::CGP::DataOut::DB::Session=HASH(0x35a84c0) => 2015-06-24 14:40:52 +0000
from a code change (applied by putting a modified copy of the module
earlier in $PERL5LIB)
mca@cgpfoo:~/gitwk-cgp/cgpDataOut$ diff -u /software/perl-5.16.2/lib/site_perl/5.16.2/DBIx/Class/InflateColumn/DateTime.pm lib/DBIx/Class/InflateColumn/DateTime.pm
--- /software/perl-5.16.2/lib/site_perl/5.16.2/DBIx/Class/InflateColumn/DateTime.pm 2013-04-15 16:21:57.000000000 +0100
+++ lib/DBIx/Class/InflateColumn/DateTime.pm 2015-06-24 14:09:54.776032000 +0100
@@ -171,8 +171,9 @@
# propagate for error reporting
$infcopy->{__dbic_colname} = $column;
-
my $dt = $obj->_inflate_to_datetime( $value, $infcopy );
+my $dt_txt = defined $dt ? $dt->strftime('%Y-%m-%d %H:%M:%S %z') : '(undef)';
+warn " inflate($column) $value,$obj => $dt_txt\n";
return (defined $dt)
? $obj->_post_inflate_datetime( $dt, $infcopy )
@@ -196,7 +197,9 @@
my $parser = $self->_datetime_parser;
my $preferred_method = sprintf($method_fmt, $info->{ _ic_dt_method });
my $method = $parser->can($preferred_method) || sprintf($method_fmt, 'datetime');
-
+ my $pfile = $parser; $pfile =~ s{::}{/}g; $pfile .= '.pm';
+ warn " preferred_method = $preferred_method; $parser ".
+ ($parser->VERSION)." from $INC{$pfile} ".($parser->can($preferred_method) ? "CAN" : "CANNOT")."\n";
return try {
$parser->$method($value);
}
relevant variable info,
$method_fmt = 'format_%s' or 'parse_%s';
$info->{_ic_dt_method} = 'timestamp_with_timezone'; # datatype is 'timestamp with timezone'
--
The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.