From ba8be438bb174fda02adf06d3a0691b9cdee8f11 Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Tue, 17 Feb 2009 12:58:45 +0900 Subject: [PATCH] * psycopg/typecast.c (typecast_parse_time): Fix up handling of negative timezone offsets with a non-zero minutes field. * tests/test_dates.py (DatetimeTests): Add tests for time zone parsing. The test for HH:MM:SS time zones is disabled because we don't currently support it. --- ChangeLog | 9 +++++++++ psycopg/typecast.c | 2 +- tests/test_dates.py | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index da412b1c..b8a57238 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-02-17 James Henstridge + + * psycopg/typecast.c (typecast_parse_time): Fix up handling of + negative timezone offsets with a non-zero minutes field. + + * tests/test_dates.py (DatetimeTests): Add tests for time zone + parsing. The test for HH:MM:SS time zones is disabled because we + don't currently support it. + 2009-02-16 Federico Di Gregorio * FreeBSD now has round(). Modified config.h as suggested by diff --git a/psycopg/typecast.c b/psycopg/typecast.c index dcd9b376..a21b30f6 100644 --- a/psycopg/typecast.c +++ b/psycopg/typecast.c @@ -155,7 +155,7 @@ typecast_parse_time(const char* s, const char** t, Py_ssize_t* len, } if (t != NULL) *t = s; - *tz = tzs * tzhh*60 + tzmm; + *tz = tzs * (tzhh * 60 + tzmm); if (*us != 0) { while (usd++ < 6) *us *= 10; diff --git a/tests/test_dates.py b/tests/test_dates.py index ff6f8551..eda4e893 100644 --- a/tests/test_dates.py +++ b/tests/test_dates.py @@ -136,7 +136,10 @@ class DatetimeTests(unittest.TestCase, CommonDatetimeTestsMixin): self.check_timezone(curs, "+01:15", 4500) self.check_timezone(curs, "-01:15", -4500) - def test_parse_datetime_timezone_hours_minutes_seconds(self): + # This test is disabled because we don't support parsing second + # resolution timezone offsets and Python wouldn't handle them even + # if we did. + def disabled_test_parse_datetime_timezone_hours_minutes_seconds(self): conn = psycopg2.connect(tests.dsn) curs = conn.cursor() self.check_timezone(curs, "+01:15:42", 4542)