[Bast-commits] r8500 - in
DBIx-Class/0.08/branches/ic_dt_post_inflate/lib/DBIx: .
Class/InflateColumn
boghead at dev.catalyst.perl.org
boghead at dev.catalyst.perl.org
Mon Feb 1 22:42:14 GMT 2010
Author: boghead
Date: 2010-02-01 22:42:14 +0000 (Mon, 01 Feb 2010)
New Revision: 8500
Modified:
DBIx-Class/0.08/branches/ic_dt_post_inflate/lib/DBIx/Class.pm
DBIx-Class/0.08/branches/ic_dt_post_inflate/lib/DBIx/Class/InflateColumn/DateTime.pm
Log:
- Add _post_inflate_datetime and _pre_deflate_datetime to InflateColumn::DateTime to allow
for modifying DateTime objects after inflation or before deflation.
Modified: DBIx-Class/0.08/branches/ic_dt_post_inflate/lib/DBIx/Class/InflateColumn/DateTime.pm
===================================================================
--- DBIx-Class/0.08/branches/ic_dt_post_inflate/lib/DBIx/Class/InflateColumn/DateTime.pm 2010-02-01 22:38:13 UTC (rev 8499)
+++ DBIx-Class/0.08/branches/ic_dt_post_inflate/lib/DBIx/Class/InflateColumn/DateTime.pm 2010-02-01 22:42:14 UTC (rev 8500)
@@ -178,21 +178,12 @@
$self->throw_exception ("Error while inflating ${value} for ${column} on ${self}: $err");
}
- $dt->set_time_zone($timezone) if $timezone;
- $dt->set_locale($locale) if $locale;
- return $dt;
+ return $obj->_post_inflate_datetime( $dt, \%info );
},
deflate => sub {
my ($value, $obj) = @_;
- if ($timezone) {
- carp "You're using a floating timezone, please see the documentation of"
- . " DBIx::Class::InflateColumn::DateTime for an explanation"
- if ref( $value->time_zone ) eq 'DateTime::TimeZone::Floating'
- and not $info{floating_tz_ok}
- and not $ENV{DBIC_FLOATING_TZ_OK};
- $value->set_time_zone($timezone);
- $value->set_locale($locale) if $locale;
- }
+
+ $value = $obj->_pre_deflate_datetime( $value, \%info );
$obj->_deflate_from_datetime( $value, \%info );
},
}
@@ -224,6 +215,65 @@
shift->result_source->storage->datetime_parser (@_);
}
+sub _post_inflate_datetime {
+ my( $self, $dt, $info ) = @_;
+
+ my $timezone;
+ if (exists $info->{timezone}) {
+ $timezone = $info->{timezone};
+ }
+ elsif (exists $info->{extra} and exists $info->{extra}{timezone}) {
+ $timezone = $info->{extra}{timezone};
+ }
+
+ my $locale;
+ if (exists $info->{locale}) {
+ $locale = $info->{locale};
+ }
+ elsif (exists $info->{extra} and exists $info->{extra}{locale}) {
+ $locale = $info->{extra}{locale};
+ }
+
+ $dt->set_time_zone($timezone) if $timezone;
+ $dt->set_locale($locale) if $locale;
+
+ return $dt;
+}
+
+sub _pre_deflate_datetime {
+ my( $self, $dt, $info ) = @_;
+
+ my $timezone;
+ if (exists $info->{timezone}) {
+ $timezone = $info->{timezone};
+ }
+ elsif (exists $info->{extra} and exists $info->{extra}{timezone}) {
+ $timezone = $info->{extra}{timezone};
+ }
+
+ my $locale;
+ if (exists $info->{locale}) {
+ $locale = $info->{locale};
+ }
+ elsif (exists $info->{extra} and exists $info->{extra}{locale}) {
+ $locale = $info->{extra}{locale};
+ }
+
+ if ($timezone) {
+ carp "You're using a floating timezone, please see the documentation of"
+ . " DBIx::Class::InflateColumn::DateTime for an explanation"
+ if ref( $dt->time_zone ) eq 'DateTime::TimeZone::Floating'
+ and not $info->{floating_tz_ok}
+ and not $ENV{DBIC_FLOATING_TZ_OK};
+
+ $dt->set_time_zone($timezone);
+ }
+
+ $dt->set_locale($locale) if $locale;
+
+ return $dt;
+}
+
1;
__END__
Modified: DBIx-Class/0.08/branches/ic_dt_post_inflate/lib/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/ic_dt_post_inflate/lib/DBIx/Class.pm 2010-02-01 22:38:13 UTC (rev 8499)
+++ DBIx-Class/0.08/branches/ic_dt_post_inflate/lib/DBIx/Class.pm 2010-02-01 22:42:14 UTC (rev 8500)
@@ -227,6 +227,8 @@
bluefeet: Aran Deltac <bluefeet at cpan.org>
+boghead: Bryan Beeley <cpan at beeley.org>
+
bricas: Brian Cassidy <bricas at cpan.org>
brunov: Bruno Vecchi <vecchi.b at gmail.com>
More information about the Bast-commits
mailing list