Hi,

just a FYI.
My db of choice is Postgres, and hence I use DateTime::Format::Pg a lot,
but there's a little bit of problem when it comes to dealing with
datetime types with time zone.

DateTime.pm apparently only supports offset strings in the form of

  [-+]\d\d\d\d

such as

  +0900

but this fails:

  +09

my installation of Postgres, which had a default setting as far as time
zones come, prints out time offsets in the form of +09, not +0900, so
this was causing problems.

I don't know what the best solution is (fix datetime.pm so that it
accepts +09? fix Pg.pm else where?), but here's a hack that worked for me:

Index: lib/DateTime/Format/Pg.pm
===================================================================
RCS file:
/cvsroot/perl-date-time/modules/DateTime-Format-Pg/lib/DateTime/Format/Pg.pm,v
retrieving revision 1.11
diff -d -u -r1.11 Pg.pm
--- lib/DateTime/Format/Pg.pm   20 Jun 2004 08:46:04 -0000      1.11
+++ lib/DateTime/Format/Pg.pm   1 Aug 2004 23:17:58 -0000
@@ -324,6 +324,11 @@
     $args{'parsed'}->{'time_zone'} = $stz || 'floating';
   }

+  # Fix time offset where the time zone is [-+]\d\d (add "00" to the end)
+  #
+  elsif($args{'parsed'}->{'time_zone'} =~ /^[-\+]\d\d$/) {
+    $args{'parsed'}->{'time_zone'} = $args{'parsed'}->{'time_zone'} . "00";
+  }
   return 1;
 }

--d

Reply via email to