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, either using Z as the timezone or without timezone information. This is the same format produced by isodatetime and is compatible with Kubernetes and the IVOA DALI standard.

Returns:

The corresponding datetime.

Return type:

datetime.datetime

Raises:

ValueError – Raised if the provided time string is not in the correct format.

Notes

When parsing input for a model, use the IvoaIsoDatetime type instead of this function. Using a model will be the normal case; this function is primarily useful in tests.