Skip to content

Commit 3786f8b

Browse files
committed
Remove limitation that seconds has two or fewer digits
- ISO 8601 doesn't seem to express that explicit limitations here are necessary.
1 parent 0511e01 commit 3786f8b

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,8 @@ cdef inline int64_t parse_iso_format_string(str ts) except? -1:
662662
r = timedelta_from_spec(number, '0', dec_unit)
663663
result += timedelta_as_neg(r, neg)
664664
else: # seconds
665-
if len(number) <= 2:
666-
r = timedelta_from_spec(number, '0', 'S')
667-
result += timedelta_as_neg(r, neg)
668-
else:
669-
raise ValueError(err_msg)
665+
r = timedelta_from_spec(number, '0', 'S')
666+
result += timedelta_as_neg(r, neg)
670667
else:
671668
raise ValueError(err_msg)
672669

pandas/tests/scalar/timedelta/test_constructors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ def test_overflow_on_construction():
234234
("P1D", Timedelta(days=1)),
235235
("P1DT1H", Timedelta(days=1, hours=1)),
236236
("P1W", Timedelta(days=7)),
237+
("PT300S", Timedelta(seconds=300)),
238+
("P1DT0H0M00000000000S", Timedelta(days=1)),
237239
],
238240
)
239241
def test_iso_constructor(fmt, exp):
@@ -247,7 +249,6 @@ def test_iso_constructor(fmt, exp):
247249
"PDTHMS",
248250
"P0DT999H999M999S",
249251
"P1DT0H0M0.0000000000000S",
250-
"P1DT0H0M00000000000S",
251252
"P1DT0H0M0.S",
252253
],
253254
)

0 commit comments

Comments
 (0)