bmizerany/pq — pull request #54 by jgallagher (2012-11-07 06:38:16+00:00)
Title: Fix for timestamp with time zone issues

I ran into an issue with timestamps with time zones using pq today. For some reason, times that were being formatted in encode() were not including the time zone, so when I would insert a timestamp and then select it back, it would be off by 5 hours (as I'm in US/Eastern). I wrote up a test to address this, and discovered two other small issues:

- the timeFormat was truncating the microseconds (Postgres supports 1 microsecond resolution, but the timeFormat was rounding to 100 microseconds)
- timezones with "strange" offsets (like Australia/Darwin) were not being handled properly, as mentioned in issue #51

I believe the test and attached patches address my original issue as well as both of these. The code attached to #51 unfortunately breaks for people who are in "normal" timezone offsets, as Postgres appears to send back different timestamp formats in the two cases (e.g., for US/Eastern it will send back "...-05" but for Australia/Darwin it will send back "...+09:30"). I patched mustParse to look for the colon and adjust the format appropriately.