parse_isodatetime

safir.datetime.parse_isodatetime(time_string)

Parse a string in a standard ISO date format.

Parameters:

time_string (str) – Date and time formatted as an ISO 8601 date and time using Z as the time zone. This is the same format produced by isodatetime and is compatible with Kubernetes and the IVOA UWS standard.

Returns:

The corresponding datetime.datetime.

Return type:

datetime.datetime

Raises:

ValueError – The provided time_string is not in the correct format.

Notes

When parsing input for a model, use safir.pydantic.normalize_isodatetime instead of this function. Using a model will be the normal case; this function is primarily useful in tests or for the special parsing cases required by the IVOA UWS standard.