flowbber.utils.iso8601

Utilities to handle ISO 8601 formatted dates.

Functions

flowbber.utils.iso8601.iso8601_to_datetime(date_string)

Converts a date of the format YYYY:MM:DDTHH:MM:SS (ISO 8601) to a datetime object.

This function is somewhat analogous to:

from datetime import datetime
datetime.fromisoformat('2019-08-05T14:38:13')

But since datetime.fromisoformat() was added only in Python 3.7 this function is left for backward compatibility.

Parameters
date_string (str) – Date string.
Returns
Datetime object.
flowbber.utils.iso8601.datetime_to_iso8601(date)

Converts a datetime object to a date string of the format YYYY:MM:DDTHH:MM:SS (ISO 8601).

This function is analogous to:

from datetime import datetime
datetime.now().replace(microsecond=0).isoformat()
Parameters
date (datetime) – Datetime object.
Returns
string with the date.

Classes

class flowbber.utils.iso8601.DateTimeJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Custom JSON enconder that converts any datetime object to a ISO 8601 date string.

Inheritance

Inheritance diagram of DateTimeJSONEncoder

Variables

flowbber.utils.iso8601.json_dumps

A json.dumps compatible function that knows how to serialize datetime objects into ISO 8601 strings.

functools.partial(<function dumps at 0x7f1b08adc7b8>, cls=<class 'flowbber.utils.iso8601.DateTimeJSONEncoder'>)