MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / dst

Method dst

tests/test_code/py/pytz/reference.py:117–135  ·  view source on GitHub ↗
(self, dt)

Source from the content-addressed store, hash-verified

115 return self.stdoffset + self.dst(dt)
116
117 def dst(self, dt):
118 if dt is None or dt.tzinfo is None:
119 # An exception may be sensible here, in one or both cases.
120 # It depends on how you want to treat them. The default
121 # fromutc() implementation (called by the default astimezone()
122 # implementation) passes a datetime with dt.tzinfo is self.
123 return ZERO
124 assert dt.tzinfo is self
125
126 # Find first Sunday in April & the last in October.
127 start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
128 end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
129
130 # Can't compare naive to aware objects, so strip the timezone from
131 # dt first.
132 if start <= dt.replace(tzinfo=None) < end:
133 return HOUR
134 else:
135 return ZERO
136
137Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
138Central = USTimeZone(-6, "Central", "CST", "CDT")

Callers 2

tznameMethod · 0.95
utcoffsetMethod · 0.95

Calls 1

first_sunday_on_or_afterFunction · 0.85

Tested by

no test coverage detected