Server : Apache System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : palandch ( 1163) PHP Version : 7.1.33 Disable Function : NONE Directory : /opt/imunify360/venv/lib64/python3.11/site-packages/babel/localtime/ |
""" babel.localtime._fallback ~~~~~~~~~~~~~~~~~~~~~~~~~ Emulated fallback local timezone when all else fails. :copyright: (c) 2013-2023 by the Babel Team. :license: BSD, see LICENSE for more details. """ import datetime import time STDOFFSET = datetime.timedelta(seconds=-time.timezone) DSTOFFSET = datetime.timedelta(seconds=-time.altzone) if time.daylight else STDOFFSET DSTDIFF = DSTOFFSET - STDOFFSET ZERO = datetime.timedelta(0) class _FallbackLocalTimezone(datetime.tzinfo): def utcoffset(self, dt: datetime.datetime) -> datetime.timedelta: if self._isdst(dt): return DSTOFFSET else: return STDOFFSET def dst(self, dt: datetime.datetime) -> datetime.timedelta: if self._isdst(dt): return DSTDIFF else: return ZERO def tzname(self, dt: datetime.datetime) -> str: return time.tzname[self._isdst(dt)] def _isdst(self, dt: datetime.datetime) -> bool: tt = (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1) stamp = time.mktime(tt) tt = time.localtime(stamp) return tt.tm_isdst > 0