utils.snapshot_store.parse_snapshot_timestamp

utils.snapshot_store.parse_snapshot_timestamp(path)

Parse the UTC timestamp encoded in a snapshot filename stem.

The stem must be formatted as %Y%m%dT%H%M%SZ (e.g. 20260611T040000Z), which is valid ISO-8601-basic and parseable by pd.Timestamp.

Parameters

Name Type Description Default
path Path File whose stem encodes the snapshot timestamp. required

Returns

Name Type Description
pd.Timestamp | None A timezone-aware pd.Timestamp in UTC, or None when the stem
pd.Timestamp | None cannot be parsed (a WARNING is logged naming the file).

Examples

>>> from pathlib import Path
>>> from spotforecast2_safe.utils.snapshot_store import parse_snapshot_timestamp
>>> ts = parse_snapshot_timestamp(Path("20260611T040000Z.csv"))
>>> ts
Timestamp('2026-06-11 04:00:00+0000', tz='UTC')
>>> parse_snapshot_timestamp(Path("bad_name.csv")) is None
True