libearth.tz — Basic timezone implementations¶
Almost of this module is from the official documentation of
datetime module in Python standard library.
-
libearth.tz.utc¶ (
Utc,datetime.timezone) Thetzinfoinstance that represents UTC. It’s an instance ofUtcin Python 2 (which provide no built-in fixed-offsettzinfoimplementation), and an instance oftimezonewith zero offset in Python 3.
-
class
libearth.tz.FixedOffset(offset, name=None)¶ Fixed offset in minutes east from UTC.
>>> kst = FixedOffset(9 * 60, name='Asia/Seoul') # KST +09:00 >>> current = now() >>> current datetime.datetime(2013, 8, 15, 3, 18, 37, 404562, tzinfo=libearth.tz.Utc()) >>> current.astimezone(kst) datetime.datetime(2013, 8, 15, 12, 18, 37, 404562, tzinfo=<libearth.tz.FixedOffset Asia/Seoul>)
-
class
libearth.tz.Utc¶ UTC.
In most cases, it doesn’t need to be directly instantiated: there’s already the
utcvalue.
-
libearth.tz.guess_tzinfo_by_locale(language, country=None)¶ Guess the most commonly used time zone from the given locale.
Parameters: Returns: the most commonly used time zone, or
Noneif can’t guessReturn type: New in version 0.3.0.