Utils()¶
- class Utils¶
This class is a utility class.
- static date()¶
Alias of
now()
.- Returns:
ISO 8601 date string
- Return type:
string
- static date_to_iso(date, format='%Y/%m/%d')¶
Format the date to ISO string.
- Parameters:
date (string) – The date string
format (string, optional) – The date format. Default is ‘%Y/%m/%d’
Tip
Check the [Python documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes) to customize the format
- Returns:
Formated ISO date string
- Return type:
string
- static datetime(date)¶
Transform the ISO string date into a Python datetime object.
- Parameters:
datetime (string) – The ISO date string
- Returns:
The datetime object from the date string
- Return type:
datetime
- static duration(days=0, hours=0, minutes=0)¶
Generate an ISO 8601 duration string.
- Parameters:
days (number) – The number of days to add
hours (number) – The number of hours to add
minutes (number) – The number of minutes to add
- Returns:
ISO 8601 duration string
- Return type:
string
- static format_date(date, format='%Y/%m/%d')¶
Format the date.
- Parameters:
date (string) – The ISO date string
format (string, optional) – The desired date format. Default is ‘%Y/%m/%d’
Tip
Check the [Python documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes) to customize the format
- Returns:
Formated date string
- Return type:
string
- static humanize_duration(duration)¶
Humanize an ISO duration.
- Parameters:
duration (string) – The ISO duration string
- Returns:
Humanized duration string
- Return type:
string
- static now()¶
Get current date/time as an ISO 8601 date string.
- Returns:
ISO 8601 date string
- Return type:
string