summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgweis <gerhard.weis@gmail.com>2017-10-13 04:21:08 (GMT)
committerGitHub <noreply@github.com>2017-10-13 04:21:08 (GMT)
commitf0e777df9fe8cb13e2cbfb938e0a0825b88ff679 (patch)
tree97266f8d9796d4f1d2cbca929a929823a175b3fa
parent4d704b97de5e8269c578a6ab54cedf9004d39bd3 (diff)
parent5988e988f5882300e55316abadce0a443474e458 (diff)
downloadisodate-f0e777df9fe8cb13e2cbfb938e0a0825b88ff679.tar.gz
Merge pull request #45 from usrenmae/master
Be able to recognize time zones with fractional hours
-rw-r--r--src/isodate/isotzinfo.py2
-rw-r--r--src/isodate/tests/test_datetime.py10
-rw-r--r--src/isodate/tests/test_time.py6
3 files changed, 17 insertions, 1 deletions
diff --git a/src/isodate/isotzinfo.py b/src/isodate/isotzinfo.py
index 263afd7..a805ebe 100644
--- a/src/isodate/isotzinfo.py
+++ b/src/isodate/isotzinfo.py
@@ -35,7 +35,7 @@ from isodate.isoerror import ISO8601Error
from isodate.tzinfo import UTC, FixedOffset, ZERO
TZ_REGEX = r"(?P<tzname>(Z|(?P<tzsign>[+-])"\
- r"(?P<tzhour>[0-9]{2})(:(?P<tzmin>[0-9]{2}))?)?)"
+ r"(?P<tzhour>[0-9]{2})(:?(?P<tzmin>[0-9]{2}))?)?)"
TZ_RE = re.compile(TZ_REGEX)
diff --git a/src/isodate/tests/test_datetime.py b/src/isodate/tests/test_datetime.py
index 3cdfe42..85c822f 100644
--- a/src/isodate/tests/test_datetime.py
+++ b/src/isodate/tests/test_datetime.py
@@ -63,6 +63,16 @@ TEST_CASES = [('19850412T1015', datetime(1985, 4, 12, 10, 15),
'+0400'),),
DATE_EXT_WEEK_COMPLETE + 'T' + TIME_EXT_MINUTE + TZ_HOUR,
'1985-W15-5T10:15+04'),
+ ('1985-W15-5T10:15-0430',
+ datetime(1985, 4, 12, 10, 15, tzinfo=FixedOffset(-4, -30,
+ '-0430'),),
+ DATE_EXT_WEEK_COMPLETE + 'T' + TIME_EXT_MINUTE + TZ_BAS,
+ '1985-W15-5T10:15-0430'),
+ ('1985-W15-5T10:15+04:45',
+ datetime(1985, 4, 12, 10, 15, tzinfo=FixedOffset(4, 45,
+ '+04:45'),),
+ DATE_EXT_WEEK_COMPLETE + 'T' + TIME_EXT_MINUTE + TZ_EXT,
+ '1985-W15-5T10:15+04:45'),
('20110410T101225.123000Z',
datetime(2011, 4, 10, 10, 12, 25, 123000, tzinfo=UTC),
DATE_BAS_COMPLETE + 'T' + TIME_BAS_COMPLETE + ".%f" + TZ_BAS,
diff --git a/src/isodate/tests/test_time.py b/src/isodate/tests/test_time.py
index 7dfd0c0..fe96dab 100644
--- a/src/isodate/tests/test_time.py
+++ b/src/isodate/tests/test_time.py
@@ -83,6 +83,12 @@ TEST_CASES = [('232050', time(23, 20, 50), TIME_BAS_COMPLETE + TZ_BAS),
('15:27:46-05', time(15, 27, 46,
tzinfo=FixedOffset(-5, -0, '-05:00')),
TIME_EXT_COMPLETE + TZ_HOUR),
+ ('15:27:46-05:30', time(15, 27, 46,
+ tzinfo=FixedOffset(-5, -30, '-05:30')),
+ TIME_EXT_COMPLETE + TZ_EXT),
+ ('15:27:46-0545', time(15, 27, 46,
+ tzinfo=FixedOffset(-5, -45, '-0545')),
+ TIME_EXT_COMPLETE + TZ_BAS),
('1:17:30', None, TIME_EXT_COMPLETE)]