Utils Dates

inyoka.utils.dates

Various utilities for datetime handling.

copyright:
  1. 2007-2026 by the Inyoka Team, see AUTHORS for more details.

license:

BSD, see LICENSE for more details.

inyoka.utils.dates._localtime(val)
inyoka.utils.dates.datetime_to_timezone(dt)

Convert a datetime object to the user’s timezone or the instance default timezone.

If the object is None, it’s returned unchanged.

inyoka.utils.dates.format_date(value, arg='DATE_FORMAT')
inyoka.utils.dates.format_datetime(value, arg='DATETIME_FORMAT')
inyoka.utils.dates.format_time(value, arg='TIME_FORMAT')
inyoka.utils.dates.format_timetz(value, arg='TIME_FORMAT')
inyoka.utils.dates.get_timezone_list()
Returns a set of available timezones.
  • the set is only created once on the first call and cached afterwards

  • it excludes deprecated names (taken from the IANA’s Time Zone Database)

The used code is from Adam Johnson’s blog post https://adamj.eu/tech/2021/05/06/how-to-list-all-timezones-in-python/ © 2021 All rights reserved. Code samples are public domain unless otherwise noted.

inyoka.utils.dates.naturalday(value, arg='DATE_FORMAT')