Skip to main content

parse_time

Parse a string and return a datetime.time.

This function doesn't support time zone offsets.

Raise ValueError if the input is well formatted but not a valid time.
Return None if the input isn't well formatted, in particular if it
contains an offset.
def parse_time(
value: str
) - > datetime.time

Parse a string and return a datetime.time. This function doesn't support time zone offsets. Raise ValueError if the input is well formatted but not a valid time. Return None if the input isn't well formatted, in particular if it contains an offset.

Parameters

NameTypeDescription
valuestrThe ISO 8601 formatted string or time-like string to be converted into a time object.

Returns

TypeDescription
datetime.timeA naive time object representing the parsed input, or None if the format is invalid or contains an offset.