Skip to content

Commit

Permalink
Work around Pg's sub-second formatting and DateTime::Parser::ISO8601
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmv committed Nov 4, 2012
1 parent ebf655c commit ecdcb17
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Jifty/DBI/Filter/DateTime.pm
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ sub decode {
# but we need Jifty::DBI::Handle here to get DB type

my $str = join('T', split ' ', $$value_ref, 2);

# The ISO8601 parser accepts 2012-11-04T12:34:56+00
# and 2012-11-04T12:34:56.789+00:00
# but not 2012-11-04T12:34:56.789+00
# Postgres returns sub-second times as the last one; append ":00" to
# change it into the acceptable second option.
$str .= ":00" if $str =~ /\d\.\d+[+-]\d\d$/;

my $dt;
eval { $dt = $self->_parser->parse_datetime($str) };

Expand Down

0 comments on commit ecdcb17

Please sign in to comment.