From 3ef3a24aeeeb468451daff471d50ceed2f8c2421 Mon Sep 17 00:00:00 2001 From: Eugen Konkov Date: Wed, 28 Oct 2020 19:05:51 +0200 Subject: [PATCH] Set formatter class to display correct data while viewing value --- lib/DBIx/Class/InflateColumn/DateTime.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index 7abf5acfe..199c799fb 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -173,11 +173,14 @@ sub register_column { $infcopy->{__dbic_colname} = $column; my $dt = $obj->_inflate_to_datetime( $value, $infcopy ); + defined $dt or return undef; - return (defined $dt) - ? $obj->_post_inflate_datetime( $dt, $infcopy ) - : undef - ; + + # By default set same formatter class as for parsing + my $parser = $obj->_datetime_parser; + $parser && $dt->set_formatter( $parser ); + + return $obj->_post_inflate_datetime( $dt, $infcopy ) }, deflate => sub { my ($value, $obj) = @_;