Skip to content

[C++] strptime timestamp parser wraps years that do not fit in 16 bits #54646

Closed

Description

@pearu

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

With %s, a number of seconds whose year is out of range gives a wrong timestamp instead of failing:

import pyarrow as pa
import pyarrow.compute as pc

for value in ["1584282600", "1000000000000000", "67768036000000000"]:
    result = pc.strptime(pa.array([value]), format="%s", unit="s")
    print(pc.strftime(result, format="%Y-%m-%d %H:%M:%S")[0])

Output on Linux and macOS (pyarrow 27.0.0.dev18):

2020-03-15 14:30:00
-28716-07-05 01:46:40
1893-12-04 12:26:40

The parser computes the year as tm_year + 1900, which overflows int for the last value, and passes it to date::year, which holds 16 bits. Expected is a parse failure for the last two values.

Found while working on #50146.

Component(s)

C++

Activity

  1. added a commit that references this issue on Oct 21, 2026
  2. added a commit that references this issue on Oct 22, 2026
  3. added this to the 27.0.0 milestone on Oct 22, 2026
  4. kou commented on Oct 22, 2026

    @kou
    Member

    Issue resolved by pull request 54658
    #54658

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions