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

Method fromutc

Doc/includes/tzinfo_examples.py:157–172  ·  view source on GitHub ↗
(self, when)

Source from the content-addressed store, hash-verified

155 return ZERO
156
157 def fromutc(self, when):
158 assert when.tzinfo is self
159 start, end = us_dst_range(when.year)
160 start = start.replace(tzinfo=self)
161 end = end.replace(tzinfo=self)
162 std_time = when + self.stdoffset
163 dst_time = std_time + HOUR
164 if end <= dst_time < end + HOUR:
165 # Repeated hour
166 return std_time.replace(fold=1)
167 if std_time < start or dst_time >= end:
168 # Standard time
169 return std_time
170 if start <= std_time < end - HOUR:
171 # Daylight saving time
172 return dst_time
173
174
175Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")

Callers

nothing calls this directly

Calls 2

us_dst_rangeFunction · 0.85
replaceMethod · 0.45

Tested by

no test coverage detected