codekingpro/portable-devtools
114k
1"""2 babel.localtime3 ~~~~~~~~~~~~~~~4 5 Babel specific fork of tzlocal to determine the local timezone6 of the system.7 8 :copyright: (c) 2013-2024 by the Babel Team.9 :license: BSD, see LICENSE for more details.10"""11 12import datetime13import sys14 15if sys.platform == 'win32':16 from babel.localtime._win32 import _get_localzone17else:18 from babel.localtime._unix import _get_localzone19 20 21# TODO(3.0): the offset constants are not part of the public API22# and should be removed23from babel.localtime._fallback import (24 DSTDIFF, # noqa: F40125 DSTOFFSET, # noqa: F40126 STDOFFSET, # noqa: F40127 ZERO, # noqa: F40128 _FallbackLocalTimezone,29)30 31 32def get_localzone() -> datetime.tzinfo:33 """Returns the current underlying local timezone object.34 Generally this function does not need to be used, it's a35 better idea to use the :data:`LOCALTZ` singleton instead.36 """37 return _get_localzone()38 39 40try:41 LOCALTZ = get_localzone()42except LookupError:43 LOCALTZ = _FallbackLocalTimezone()44 