Skip to content

[C++][Python] strptime fails to parse with %p on Windows #31971

Description

@asfimport

As reported in #13111 parsing a timestamp with %p will fail on Windows. This is probably due to issues with vendored strptime on Windows locales.
We should explore which flags can be enabled and how. Strptime tests suite should be expanded https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/scalar_string_test.cc#L1842-L1890.

Reporter: Rok Mihevc / @rok
Watchers: Rok Mihevc / @rok

Related issues:

Note: This issue was originally created as ARROW-16618. Please see the migration documentation for further details.

Activity

  1. asfimport commented on May 19, 2022

    @asfimport
    Author

    Antoine Pitrou / @pitrou:
    As I said on the Linked GH issue:

    The vendored strptime implementation does support %p, but we have to disable it on Windows because the behavior is locale-dependent and it's not easy to support there.

    (of course, we may support it in a non-locale-dependent way, i.e. always use the same values as a "C" Unix locale)

  2. asfimport commented on May 19, 2022

    @asfimport
    Author
  3. asfimport commented on May 19, 2022

    @asfimport
    Author

    Antoine Pitrou / @pitrou:
    For the record, here are the changes we applied to the vendored strptime:
    https://gist.github.com/pitrou/d1d23ad2fdae4be34e737c14c8ae7443

    You can see that, on Windows, we disable any locale-specific codes because they use nl_langinfo which is unavailable.

  4. asfimport commented on May 31, 2022

    @asfimport
    Author

    Joris Van den Bossche / @jorisvandenbossche:
    We could maybe adapt the patch to the vendored strptime to raise a more informative error if it encounters %p if that is explicitly not supported?

  5. asfimport commented on May 31, 2022

    @asfimport
    Author

    Rok Mihevc / @rok:
    That would be useful indeed. Judging by ibis we might want to check %c, %x and %X too.

  6. pearu commented on Jun 11, 2026

    @pearu
    Contributor

    PR #50146 (primarily about CSV date/time parsing) includes a fix for this: %p in the vendored musl strptime used on Windows was compiled out because nl_langinfo() (the source of the AM/PM strings) is unavailable there. The PR adds static C-locale tables, after which %p correctly adjusts %I hours on Windows (02:30 PM → 14:30). Validated on Windows CI across MinGW, MSVC, and ARM64 MSVC builds.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions