Skip to content

Commit

Permalink
Reverted version increment; added tests to get coverage to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
jadchaar committed Aug 19, 2019
1 parent 9940542 commit 66d09f8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion arrow/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.15.0"
__version__ = "0.14.5"
10 changes: 2 additions & 8 deletions arrow/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def parse_iso(self, datetime_string):
)

has_tz = len(time_parts) == 2
has_hours = hours is not None
has_minutes = minutes is not None
has_seconds = seconds is not None
has_subseconds = subseconds is not None
Expand All @@ -188,12 +187,8 @@ def parse_iso(self, datetime_string):
time_string = "HH{time_sep}mm{time_sep}ss".format(time_sep=time_sep)
elif has_minutes:
time_string = "HH{time_sep}mm".format(time_sep=time_sep)
elif has_hours:
time_string = "HH"
else:
raise ParserError(
"Invalid time component provided. Please specify a format or provide a valid time component in the basic or extended ISO 8601 time format."
)
time_string = "HH"

if has_space_divider:
formats = ["{} {}".format(f, time_string) for f in formats]
Expand Down Expand Up @@ -366,8 +361,7 @@ def _build_datetime(parts):
timestamp = parts.get("timestamp")

if timestamp is not None:
tz_utc = tz.tzutc()
return datetime.fromtimestamp(timestamp, tz=tz_utc)
return datetime.fromtimestamp(timestamp, tz=tz.tzutc())

day_of_year = parts.get("day_of_year")

Expand Down
25 changes: 25 additions & 0 deletions tests/parser_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ def test_parse_timestamp(self):
self.parser.parse("{:f}".format(float_timestamp), "X"), self.expected
)

# test handling of ns timestamp (arrow will round to 6 digits regardless)
self.expected = datetime.fromtimestamp(float_timestamp, tz=tz_utc)
self.assertEqual(
self.parser.parse("{:f}123".format(float_timestamp), "X"), self.expected
)

# test ps timestamp (arrow will round to 6 digits regardless)
self.expected = datetime.fromtimestamp(float_timestamp, tz=tz_utc)
self.assertEqual(
self.parser.parse("{:f}123456".format(float_timestamp), "X"), self.expected
)

# NOTE: timestamps cannot be parsed from natural language strings (by removing the ^...$) because it will
# break cases like "15 Jul 2000" and a format list (see issue #447)
with self.assertRaises(ParserError):
Expand Down Expand Up @@ -743,6 +755,19 @@ def test_YYYY_MM_DDTHH_mm(self):
self.parser.parse_iso("2013-02-03T04:05"), datetime(2013, 2, 3, 4, 5)
)

def test_YYYY_MM_DDTHH(self):

self.assertEqual(
self.parser.parse_iso("2013-02-03T04"), datetime(2013, 2, 3, 4)
)

def test_YYYY_MM_DDTHHZ(self):

self.assertEqual(
self.parser.parse_iso("2013-02-03T04+01:00"),
datetime(2013, 2, 3, 4, tzinfo=tz.tzoffset(None, 3600)),
)

def test_YYYY_MM_DDTHH_mm_ssZ(self):

self.assertEqual(
Expand Down

0 comments on commit 66d09f8

Please sign in to comment.