Skip to content

[C++] strptime timestamp parser wraps leap seconds into the next minute #54647

Open

Description

@pearu

Describe the bug, including details regarding any error messages, version, and platform.

Timestamp parsing with a strptime format adds a seconds value of 60 (on Linux also 61) to the time of day, so it wraps into the next minute:

import pyarrow as pa
import pyarrow.compute as pc

for value in ["2020-12-31 23:59:60", "2020-12-31 23:59:61"]:
    try:
        print(pc.strptime(pa.array([value]), format="%Y-%m-%d %H:%M:%S", unit="s")[0])
    except pa.ArrowInvalid as e:
        print(e)

Output on Linux (pyarrow 27.0.0.dev18):

2021-01-01 00:00:00
2021-01-01 00:00:01

Output on macOS and Windows:

2021-01-01 00:00:00
Failed to parse string: '2020-12-31 23:59:61' as a scalar of type timestamp[s]

Expected is a parse failure, as with the ISO-8601 parser: pa.array(["2020-12-31 23:59:60"]).cast(pa.timestamp("s")) raises ArrowInvalid: Failed to parse string: '2020-12-31 23:59:60' as a scalar of type timestamp[s].

Found while working on #50146.

Component(s)

C++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions