MCPcopy Index your code
hub / github.com/RustPython/RustPython / _local_timezone

Method _local_timezone

Lib/_pydatetime.py:2070–2085  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2068 __replace__ = replace
2069
2070 def _local_timezone(self):
2071 if self.tzinfo is None:
2072 ts = self._mktime()
2073 # Detect gap
2074 ts2 = self.replace(fold=1-self.fold)._mktime()
2075 if ts2 != ts: # This happens in a gap or a fold
2076 if (ts2 > ts) == self.fold:
2077 ts = ts2
2078 else:
2079 ts = (self - _EPOCH) // timedelta(seconds=1)
2080 localtm = _time.localtime(ts)
2081 local = datetime(*localtm[:6])
2082 # Extract TZ data
2083 gmtoff = localtm.tm_gmtoff
2084 zone = localtm.tm_zone
2085 return timezone(timedelta(seconds=gmtoff), zone)
2086
2087 def astimezone(self, tz=None):
2088 if tz is None:

Callers 1

astimezoneMethod · 0.95

Calls 5

_mktimeMethod · 0.95
replaceMethod · 0.95
timedeltaClass · 0.85
datetimeClass · 0.85
timezoneClass · 0.70

Tested by

no test coverage detected