X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FInflateColumn%2FDateTime.pm;h=7abf5acfe7e694122cb58b87083e0131007b5db5;hb=534521dac62f6ab58e83a42d4e8e3cb586db464b;hp=7b7e144e0ea3497db5b09286f871f0cada6dfdfd;hpb=bbe0a14d6df060f74123365d906fc16a4187d1ae;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index 7b7e144..7abf5ac 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -3,7 +3,7 @@ package DBIx::Class::InflateColumn::DateTime; use strict; use warnings; use base qw/DBIx::Class/; -use Carp::Clan qw/^DBIx::Class/; +use DBIx::Class::Carp; use Try::Tiny; use namespace::clean; @@ -78,8 +78,8 @@ deflation/inflation as defined in the storage class. For instance, for a C field the methods C and C would be called on deflation/inflation. If the storage class does not provide a specialized inflator/deflator, C<[parse|format]_datetime> will -be used as a fallback. See L for more information on -date formatting. +be used as a fallback. See L +for more information on date formatting. For more help with using components, see L. @@ -169,13 +169,10 @@ sub register_column { inflate => sub { my ($value, $obj) = @_; - my $dt = try - { $obj->_inflate_to_datetime( $value, $infcopy ) } - catch { - $self->throw_exception ("Error while inflating ${value} for ${column} on ${self}: $_") - unless $infcopy->{datetime_undef_if_invalid}; - undef; # rv - }; + # propagate for error reporting + $infcopy->{__dbic_colname} = $column; + + my $dt = $obj->_inflate_to_datetime( $value, $infcopy ); return (defined $dt) ? $obj->_post_inflate_datetime( $dt, $infcopy ) @@ -198,8 +195,16 @@ sub _flate_or_fallback my $parser = $self->_datetime_parser; my $preferred_method = sprintf($method_fmt, $info->{ _ic_dt_method }); - my $method = $parser->can($preferred_method) ? $preferred_method : sprintf($method_fmt, 'datetime'); - return $parser->$method($value); + my $method = $parser->can($preferred_method) || sprintf($method_fmt, 'datetime'); + + return try { + $parser->$method($value); + } + catch { + $self->throw_exception ("Error while inflating '$value' for $info->{__dbic_colname} on ${self}: $_") + unless $info->{datetime_undef_if_invalid}; + undef; # rv + }; } sub _inflate_to_datetime { @@ -300,20 +305,18 @@ use the old way you'll see a warning - please fix your code then! can be found in the documentation for L. =item Further discussion of problems inherent to the Floating timezone: - L + L and L<< $dt->set_time_zone|DateTime/"Set" Methods >> =back -=head1 AUTHOR - -Matt S. Trout - -=head1 CONTRIBUTORS - -Aran Deltac +=head1 FURTHER QUESTIONS? -=head1 LICENSE +Check the list of L. -You may distribute this code under the same terms as Perl itself. +=head1 COPYRIGHT AND LICENSE +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L.