jetblack_serialization¶
module jetblack_iso8601 ¶
Summary¶
ISO 8601
Description¶
Utilities for converting dates and durations to and from ISO 8601 format.
function jetblack_iso8601.datetime_to_iso8601 ¶
Summary¶
Convert datetime to ISO 8601
jetblack_iso8601.datetime_to_iso8601(
timestamp: datetime
) -> strfunction jetblack_iso8601.iso8601_to_datetime ¶
Summary¶
Parse an ISO 8601 datetime.
jetblack_iso8601.iso8601_to_datetime(
value: str
) -> Optional[datetime]function jetblack_iso8601.iso8601_to_timedelta ¶
Summary¶
Convert an ISO 8601 duration to a timedelta
jetblack_iso8601.iso8601_to_timedelta(
duration: str
) -> Optional[timedelta]Returns¶
Optional[timedelta]: The duration as a timedelta if the string could be parsed, otherwise None.function jetblack_iso8601.timedelta_to_iso8601 ¶
Summary¶
Convert a timedelta to an ISO 8601 duration string
Description¶
Prefers weeks to days, so a roundtrip of P7D becomes P1W. Also an zero value is removed. A zero duration becomes P0D.
jetblack_iso8601.timedelta_to_iso8601(
value: timedelta
) -> str