Functions for converting datetime.timedelta and datetime.datetime to and from ISO 8601 strings.
Converts a datetime.timedelta to an ISO 8601 duration string for JSON-ification.
Parameters: | value (datetime.timedelta) – something to convert |
---|---|
Returns: | the value after conversion |
:rtype unicode
Tries to convert the given value to a datetime.datetime. If no timezone is given, raises a ValueError.
Strings will be parsed as ISO 8601 timestamps.
If a number is provided, it will be interpreted as a UNIX timestamp, which by definition is UTC.
If a dict is provided, does datetime.datetime(**value).
If a tuple or a list is provided, does datetime.datetime(*value). Uses the timezone in the tuple or list if provided.
Parameters: | value (str | unicode | float | int | datetime.datetime | dict | list | tuple) – something to convert |
---|---|
Returns: | the value after conversion |
Return type: | datetime.datetime |
Raises: | ValueError | TypeError |
Tries to convert the given value to a datetime.timedelta.
Strings will be parsed as ISO 8601 durations.
If a number is provided, it will be interpreted as the number of seconds.
If a dict is provided, does datetime.timedelta(**value).
Parameters: | value (str | unicode | float | int | datetime.timedelta | dict) – something to convert |
---|---|
Returns: | the value after conversion |
Return type: | datetime.timedelta |