Skip to content

[C++] Detection of %z in strptime format fails in certain cases, not returning timestamp with tz=UTC #35448

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

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

#11358 refactored the timezone offset handling in string parsing (both in read_csv, casting str->timestamp and strptime).

The general rule was that if there is a %z in the format string you provide to strptime, we apply the offset and return a timestamp type with tz=UTC.
But this seems to work only in certain cases:

# space before %z -> works
>>> pc.strptime(["5/1/2020 +0100", None, "12/11/1900 -0130"], format="%m/%d/%Y %z", unit='us').type
TimestampType(timestamp[us, tz=UTC])
# no space before %z -> doesn't work
>>> pc.strptime(["5/1/2020+0100", None, "12/11/1900-0130"], format="%m/%d/%Y%z", unit='us').type
TimestampType(timestamp[us])

Component(s)

C++

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions