Skip to content

[C++] strptime fails to parse with %z on MacOS when zone offset includes ":" #34081

@ayhanfuat

Description

@ayhanfuat

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

Timezone information seems to be supported as per #29023. And it works fine on Linux:

Python 3.8.14 (default, Sep  8 2022, 00:02:07)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.9.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pyarrow

In [2]: import platform

In [3]: platform.platform()
Out[3]: 'Linux-5.15.0-1021-aws-x86_64-with-glibc2.35'

In [4]: pyarrow.__version__
Out[4]: '11.0.0'

In [5]: from pyarrow.compute import strptime

In [6]: strptime(["2012-01-01 01:02:03+01:00"], format="%Y-%m-%d %H:%M:%S%z", un
   ...: it="s")
Out[6]:
<pyarrow.lib.TimestampArray object at 0x7f80826b6520>
[
  2012-01-01 00:02:03
]

However, it raises an error on MacOS:

Python 3.8.15 (default, Oct 21 2022, 23:32:29)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pyarrow

In [2]: import platform

In [3]: platform.platform()
Out[3]: 'macOS-13.1-arm64-arm-64bit'

In [4]: pyarrow.__version__
Out[4]: '11.0.0'

In [5]: from pyarrow.compute import strptime

In [6]: strptime(["2012-01-01 01:02:03+01:00"], format="%Y-%m-%d %H:%M:%S%z", un
   ...: it="s")
---------------------------------------------------------------------------
ArrowInvalid                              Traceback (most recent call last)
Cell In [6], line 1
----> 1 strptime(["2012-01-01 01:02:03+01:00"], format="%Y-%m-%d %H:%M:%S%z", unit="s")

File ~/arrowtest/lib/python3.8/site-packages/pyarrow/compute.py:256, in _make_generic_wrapper.<locals>.wrapper(memory_pool, options, *args, **kwargs)
    254 if args and isinstance(args[0], Expression):
    255     return Expression._call(func_name, list(args), options)
--> 256 return func.call(args, options, memory_pool)

File ~/arrowtest/lib/python3.8/site-packages/pyarrow/_compute.pyx:355, in pyarrow._compute.Function.call()

File ~/arrowtest/lib/python3.8/site-packages/pyarrow/error.pxi:144, in pyarrow.lib.pyarrow_internal_check_status()

File ~/arrowtest/lib/python3.8/site-packages/pyarrow/error.pxi:100, in pyarrow.lib.check_status()

ArrowInvalid: Failed to parse string: '2012-01-01 01:02:03+01:00' as a scalar of type timestamp[s]

I've looked into the umbrella issue (#31324) but couldn't see this one. Sorry if I missed a duplicate issue.

Component(s)

Python

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