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
) Thetzinfo
instance that represents UTC. It’s an instance ofUtc
in Python 2 (which provide no built-in fixed-offsettzinfo
implementation), and an instance oftimezone
with 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
utc
value.
-
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
None
if can’t guessReturn type: New in version 0.3.0.