At 2:28 am -0700 2004-05-09, Jonah Petri wrote:
Now, the date coming out of postgres _looks_ like it is conforming to ISO 8601. DateTime::Format::Pg seems to be cool with it, too. However, the docs on DateTime::TimeZone::offset_as_seconds are pretty clear that this input will be rejected.

A couple possible explanations:
* Did DateTime::TimeZone::offset_as_seconds at some point allow 2 digit offsets? (i can't find any evidence of this...)

Does ISO8601 allow for two digit offsets (which IIRC are hours-only)?


* Did postgres at some point output data with 4 (or 6) digit offsets? (Not that I can find or remember)

I think there's some way to get it to do so. Or else the older versions did. I use DT::F::Strptime rather than DT::F:: Pg to parse my Pg timestamp_tz fields and I think I remember at some point having to change the match to allow for a two-digit offset.


* Has DateTime::Format::Pg::parse_timestamptz never worked? (one would hope not, but....)

No idea


A couple possible fixes:
* Alter DateTime::TimeZone::offset_as_seconds to accept 2 digit offsets. This seems the easiest solution, and will add this capability to all of the DateTime modules.

Only if ISO8601 allows for a two-digit offset. If it doesn't then we should implement it only in formats that have a two-digit offset.


* Alter DateTime::Format::Pg to pad the offset digits coming in from postgres. This is also fairly good, though the code would be duplicated in DT::Fmt::ISO8601 (once the date + time parsing code is written).

If not in ISO, this is the right place to do it.


* Alter my DBI layer to pad the timestamps coming out of postgres to 4 digit offsets before handing them to DateTime::Format::Pg::parse_timestamptz.

Annoying though. I remember pre-datetime I used to SELECT to_char('YYYY-MM-DD', order_date) as order_date FROM blah which is not only annoying but silly.

**** While we're talking about Pg ****

I'd like to have a way of getting all data from Pg (and all DBDs) to pass DateTime objects rather than strings. Where should this be done?

a) DBD::Pg::DateTime
b) DateTime::DBD::Pg (as above, just a different name)
c) $dbh->post_process_column_type('timestamp_tz', \&makedt)
        (would need to be done by owner of DBD::Pg)
d) DateTime::Format::DBI (wrapper around DBI to do the translations)
e) other

Cheers!
Rick

--
--------------------------------------------------------
            There are 10 kinds of people:
  those that understand binary, and those that don't.
--------------------------------------------------------
  The day Microsoft makes something that doesn't suck
    is the day they start selling vacuum cleaners
--------------------------------------------------------
"Write a wise proverb and your name will live forever."
   -- Anonymous
--------------------------------------------------------

Reply via email to