src.dackar.RCA.signal_evidence._util¶
Shared helpers for the signal-evidence package.
Centralizes the small utilities that were previously duplicated between
builder.py and historian_adapter.py (MR#49 review), so the
UTC-normalization rule below lives in exactly one place.
Functions¶
|
Parse an ISO-8601 timestamp, normalized to a UTC-aware |
|
Clamp x to the closed unit interval |
Module Contents¶
- src.dackar.RCA.signal_evidence._util.parse_dt(value)[source]¶
Parse an ISO-8601 timestamp, normalized to a UTC-aware
datetime.A naive input (no offset, e.g.
"2024-01-01T00:00:00") is assumed to be UTC and stamped withtimezone.utc, while offset-aware inputs (...+00:00/...Z) are preserved. This guarantees every downstream comparison and subtraction operates on offset-aware datetimes, avoidingTypeError: can't compare offset-naive and offset-aware datetimes.- Parameters:
value (Optional[str]) – An ISO-8601 timestamp string, or
None/empty.- Returns:
A UTC-aware
datetime, orNonewhen value is empty or cannot be parsed.- Return type:
Optional[datetime.datetime]