MCPcopy Index your code
hub / github.com/python/cpython / _local_timezone

Method _local_timezone

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

Source from the content-addressed store, hash-verified

2108 __replace__ = replace
2109
2110 def _local_timezone(self):
2111 if self.tzinfo is None:
2112 ts = self._mktime()
2113 # Detect gap
2114 ts2 = self.replace(fold=1-self.fold)._mktime()
2115 if ts2 != ts: # This happens in a gap or a fold
2116 if (ts2 > ts) == self.fold:
2117 ts = ts2
2118 else:
2119 ts = (self - _EPOCH) // timedelta(seconds=1)
2120 localtm = _time.localtime(ts)
2121 # Extract TZ data
2122 gmtoff = localtm.tm_gmtoff
2123 zone = localtm.tm_zone
2124 return timezone(timedelta(seconds=gmtoff), zone)
2125
2126 def astimezone(self, tz=None):
2127 if tz is None:

Callers 1

astimezoneMethod · 0.95

Calls 4

_mktimeMethod · 0.95
replaceMethod · 0.95
timedeltaClass · 0.85
timezoneClass · 0.85

Tested by

no test coverage detected