Closed
Description
Describe the bug, including details regarding any error messages, version, and platform.
Timestamp parsing with a strptime format rolls an impossible date over into the next month. Where the platform's strptime accepts day 00 (macOS, Windows), it is taken as the first of the month:
import pyarrow as pa
import pyarrow.compute as pc
for value in ["2021-02-30", "2021-04-31", "2021-02-00"]:
try:
print(pc.strptime(pa.array([value]), format="%Y-%m-%d", unit="s")[0])
except pa.ArrowInvalid as e:
print(e)Output on Linux (pyarrow 27.0.0.dev18):
2021-03-02 00:00:00
2021-05-01 00:00:00
Failed to parse string: '2021-02-00' as a scalar of type timestamp[s]
Output on macOS and Windows:
2021-03-02 00:00:00
2021-05-01 00:00:00
2021-02-01 00:00:00
Expected is a parse failure for all three values, as with the ISO-8601 parser: pa.array(["2021-02-30"]).cast(pa.timestamp("s")) raises ArrowInvalid: Failed to parse string: '2021-02-30' as a scalar of type timestamp[s].
Found while working on #50146.
Component(s)
C++
Activity
apacheGH-54643: [C++] Reject impossible dates and a zero day in the s…
GH-54643: [C++] Reject impossible dates and a zero day in the strptim…
kou commentedon Oct 21, 2026
Issue resolved by pull request 54657
#54657