Skip to content

Commit

Permalink
Remove limitation that seconds has two or fewer digits
Browse files Browse the repository at this point in the history
- ISO 8601 doesn't seem to express that explicit limitations here are
  necessary.
  • Loading branch information
mgmarino committed Oct 16, 2020
1 parent 0511e01 commit 3786f8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 2 additions & 5 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,8 @@ cdef inline int64_t parse_iso_format_string(str ts) except? -1:
r = timedelta_from_spec(number, '0', dec_unit)
result += timedelta_as_neg(r, neg)
else: # seconds
if len(number) <= 2:
r = timedelta_from_spec(number, '0', 'S')
result += timedelta_as_neg(r, neg)
else:
raise ValueError(err_msg)
r = timedelta_from_spec(number, '0', 'S')
result += timedelta_as_neg(r, neg)
else:
raise ValueError(err_msg)

Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/scalar/timedelta/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ def test_overflow_on_construction():
("P1D", Timedelta(days=1)),
("P1DT1H", Timedelta(days=1, hours=1)),
("P1W", Timedelta(days=7)),
("PT300S", Timedelta(seconds=300)),
("P1DT0H0M00000000000S", Timedelta(days=1)),
],
)
def test_iso_constructor(fmt, exp):
Expand All @@ -247,7 +249,6 @@ def test_iso_constructor(fmt, exp):
"PDTHMS",
"P0DT999H999M999S",
"P1DT0H0M0.0000000000000S",
"P1DT0H0M00000000000S",
"P1DT0H0M0.S",
],
)
Expand Down

0 comments on commit 3786f8b

Please sign in to comment.