Skip to content

Commit 0ac1211

Browse files
committed
Handle direct datetime strings in _apply_segments
1 parent 62129a9 commit 0ac1211

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

pointblank/validate.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18126,8 +18126,26 @@ def _apply_segments(data_tbl: Any, segments_expr: tuple[str, str]) -> Any:
1812618126
except ValueError: # pragma: no cover
1812718127
pass # pragma: no cover
1812818128

18129-
# Format 2: Datetime strings with UTC timezone like
18130-
# "2016-01-04 00:00:01 UTC.strict_cast(...)"
18129+
# Format 2: Direct datetime strings like "2016-01-04 00:00:01" (Polars 1.36+)
18130+
# These don't have UTC suffix anymore
18131+
elif (
18132+
" " in segment_str
18133+
and "UTC" not in segment_str
18134+
and "[" not in segment_str
18135+
and ".alias" not in segment_str
18136+
):
18137+
try:
18138+
parsed_dt = datetime.fromisoformat(segment_str)
18139+
# Convert midnight datetimes to dates for consistency
18140+
if parsed_dt.time() == datetime.min.time():
18141+
parsed_value = parsed_dt.date() # pragma: no cover
18142+
else:
18143+
parsed_value = parsed_dt
18144+
except ValueError: # pragma: no cover
18145+
pass # pragma: no cover
18146+
18147+
# Format 3: Datetime strings with UTC timezone like
18148+
# "2016-01-04 00:00:01 UTC.strict_cast(...)" (Polars < 1.36)
1813118149
elif " UTC" in segment_str:
1813218150
try:
1813318151
# Extract just the datetime part before "UTC"
@@ -18142,7 +18160,7 @@ def _apply_segments(data_tbl: Any, segments_expr: tuple[str, str]) -> Any:
1814218160
except (ValueError, IndexError): # pragma: no cover
1814318161
pass # pragma: no cover
1814418162

18145-
# Format 3: Bracketed expressions like ['2016-01-04']
18163+
# Format 4: Bracketed expressions like ['2016-01-04']
1814618164
elif segment_str.startswith("[") and segment_str.endswith("]"):
1814718165
try: # pragma: no cover
1814818166
# Remove [' and ']

0 commit comments

Comments
 (0)