Skip to content

Commit

Permalink
Added test for comma subsecond separator and moved setting of tz_form…
Browse files Browse the repository at this point in the history
…at down in file
  • Loading branch information
jadchaar committed Sep 8, 2019
1 parent ca1bb57 commit 3160c4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 7 additions & 7 deletions arrow/parser.py
Expand Up @@ -155,13 +155,6 @@ def parse_iso(self, datetime_string):

time_parts = re.split(r"[\+\-Z]", time_string, 1, re.IGNORECASE)

is_basic_time_format = ":" not in time_parts[0]
tz_format = "Z"

# use 'ZZ' token instead since tz offset is present in non-basic format
if len(time_parts) == 2 and ":" in time_parts[1]:
tz_format = "ZZ"

time_components = self._TIME_RE.match(time_parts[0])

if time_components is None:
Expand All @@ -178,6 +171,13 @@ def parse_iso(self, datetime_string):
has_seconds = seconds is not None
has_subseconds = subseconds is not None

is_basic_time_format = ":" not in time_parts[0]
tz_format = "Z"

# use 'ZZ' token instead since tz offset is present in non-basic format
if has_tz and ":" in time_parts[1]:
tz_format = "ZZ"

time_sep = "" if is_basic_time_format else ":"

if has_subseconds:
Expand Down
6 changes: 6 additions & 0 deletions tests/parser_tests.py
Expand Up @@ -976,6 +976,12 @@ def test_parse_subsecond(self):
self.parser.parse_iso("2013-01-01 12:30:45.987654"), self.expected
)

# use comma as subsecond separator
self.expected = datetime(2013, 1, 1, 12, 30, 45, 987654)
self.assertEqual(
self.parser.parse_iso("2013-01-01 12:30:45,987654"), self.expected
)

def test_gnu_date(self):
"""
regression tests for parsing output from GNU date(1)
Expand Down

0 comments on commit 3160c4c

Please sign in to comment.