Skip to content

[C++] string created by strftime can't be parsed by strptime #40170

Open

Description

@rohanjain101

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

pa.compute.strftime(pd.Timestamp.utcnow(), "%Y-%m-%d %z")
<pyarrow.StringScalar: '2024-02-21 +0000'>
pa.compute.strptime('2024-02-21 +0000', "%Y-%m-%d %z", "ns")
Traceback (most recent call last):
File "", line 1, in
File "D:\pd_dev_1208\Lib\site-packages\pyarrow\compute.py", line 263, in wrapper
return func.call(args, options, memory_pool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pyarrow_compute.pyx", line 385, in pyarrow._compute.Function.call
File "pyarrow\error.pxi", line 154, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow\error.pxi", line 91, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: Failed to parse string: '2024-02-21 +0000' as a scalar of type timestamp[ns]

Component(s)

C++, Python

Activity

  1. jorisvandenbossche commented on Feb 27, 2024

    @jorisvandenbossche
    Member

    Which version of pyarrow are you using? For me, using the latest dev version, this seems to work fine:

    In [8]: pa.compute.strftime(pd.Timestamp.utcnow(), "%Y-%m-%d %z")
    Out[8]: <pyarrow.StringScalar: '2024-02-27 +0000'>
    
    In [9]: pa.compute.strptime('2024-02-21 +0000', "%Y-%m-%d %z", "ns")
    Out[9]: <pyarrow.TimestampScalar: '2024-02-21T00:00:00.000000000+0000'>
    
  2. jorisvandenbossche commented on Feb 27, 2024

    @jorisvandenbossche
    Member

    Ah, and potentially the platform is more relevant information. I suppose you are using Windows (from the file paths)?

    For Windows, we have a vendored implementation for strptime, while for unix we use the system's one, I think

  3. changed the title [-]string created by strftime can't be parsed by strptime[/-] [+][C++] string created by strftime can't be parsed by strptime[/+] on Feb 27, 2024
  4. rohanjain101 commented on Feb 27, 2024

    @rohanjain101
    Author

    Yes windows with latest pyarrow. I guess it is related to the vendored implementation then.

  5. thisisnic commented on Nov 23, 2026

    @thisisnic
    Member

    Thanks for reporting this! I'm going through older bug issues to see if we can close them out or we need further action.

    This still reproduces on Windows with pyarrow 26.0.1, and it is not specific to +0000: any format containing %z fails to parse on Windows, while the same calls work on Linux and macOS. On Windows Arrow uses a vendored strptime (cpp/src/arrow/util/value_parsing.h:821), and cpp/src/arrow/vendored/musl/strptime.c has no case for %z, so it returns failure at the default: branch.

    Related: #34081 covers %z on macOS, where offsets with a colon fail.

  6. added
    Status: confirmed
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: C++Component: PythonStatus: confirmedType: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions