File tree 2 files changed +7
-1
lines changed 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ class DateTimeParser(object):
45
45
_TZ_NAME_RE = re .compile (r"\w[\w+\-/]+" )
46
46
# NOTE: timestamps cannot be parsed from natural language strings (by removing the ^...$) because it will
47
47
# break cases like "15 Jul 2000" and a format list (see issue #447)
48
- _TIMESTAMP_RE = re .compile (r"^\d+\.?\d+$" )
48
+ _TIMESTAMP_RE = re .compile (r"^-? \d+\.?\d+$" )
49
49
_TIME_RE = re .compile (r"^(\d{2})(?:\:?(\d{2}))?(?:\:?(\d{2}))?(?:([\.\,])(\d+))?$" )
50
50
51
51
_BASE_INPUT_RE_MAP = {
Original file line number Diff line number Diff line change @@ -224,6 +224,12 @@ def test_parse_timestamp(self):
224
224
self .parser .parse ("{:f}123456" .format (float_timestamp ), "X" ), self .expected
225
225
)
226
226
227
+ negative_timestamp = - 1565358758
228
+ self .expected = datetime .fromtimestamp (negative_timestamp , tz = tz_utc )
229
+ self .assertEqual (
230
+ self .parser .parse ("{:d}" .format (negative_timestamp ), "X" ), self .expected
231
+ )
232
+
227
233
# NOTE: timestamps cannot be parsed from natural language strings (by removing the ^...$) because it will
228
234
# break cases like "15 Jul 2000" and a format list (see issue #447)
229
235
with self .assertRaises (ParserError ):
You can’t perform that action at this time.
0 commit comments