Skip to content

[C++] strptime does not support %a, %b, %p and other locale directives on Windows #54641

Closed

Description

@pearu

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

On Windows, timestamp parsing with a strptime format fails when the format contains %a, %A, %b, %B, %h, %c, %p, %r, %x or %X:

import pyarrow as pa
import pyarrow.compute as pc

for value, fmt in [
    ("15-Feb-2015", "%d-%b-%Y"),
    ("15 February 2015", "%d %B %Y"),
    ("Sun 15 Feb 2015", "%a %d %b %Y"),
    ("02/15/2015 02:30 PM", "%m/%d/%Y %I:%M %p"),
]:
    try:
        print(pc.strptime(pa.array([value]), format=fmt, unit="s")[0])
    except pa.ArrowInvalid as e:
        print(e)

Output on Windows (pyarrow 27.0.0.dev18):

Failed to parse string: '15-Feb-2015' as a scalar of type timestamp[s]
Failed to parse string: '15 February 2015' as a scalar of type timestamp[s]
Failed to parse string: 'Sun 15 Feb 2015' as a scalar of type timestamp[s]
Failed to parse string: '02/15/2015 02:30 PM' as a scalar of type timestamp[s]

Expected, as on Linux and macOS:

2015-02-15 00:00:00
2015-02-15 00:00:00
2015-02-15 00:00:00
2015-02-15 14:30:00

On Windows, Arrow uses the vendored musl strptime (cpp/src/arrow/vendored/musl/strptime.c), which defines HAVE_LANGINFO only when _WIN32 is not defined, and handles these directives only under #ifdef HAVE_LANGINFO.

Found while working on #50146.

Component(s)

C++

Activity

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

    @kou
    Member

    Issue resolved by pull request 54656
    #54656

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