[Dbix-class] IC::DT default time zone support?
Mark Hedges
hedges at ucsd.edu
Fri Aug 11 03:48:29 CEST 2006
Here's an easy way to implement default timezone support for
InflateColumn::DateTime. Add a field info parameter 'time_zone'
in the column definition, if you want one.
set_time_zone bombs on undef so it cannot use chained methods.
Mark
--- /tmp/DateTime.pm 2006-08-10 18:37:29.000000000 -0700
+++ /usr/local/share/perl/5.8.8/DBIx/Class/InflateColumn/DateTime.pm 2006-08-10 18:45:34.000000000 -0700
@@ -60,7 +60,10 @@
{
inflate => sub {
my ($value, $obj) = @_;
- $obj->_datetime_parser->$parse($value);
+ my $dt = $obj->_datetime_parser->$parse($value);
+ my $tz = $info->{time_zone};
+ $dt->set_time_zone( $tz ) if $tz;
+ return $dt;
},
deflate => sub {
my ($value, $obj) = @_;
More information about the Dbix-class
mailing list