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

Method dst

Lib/test/datetimetester.py:5794–5814  ·  view source on GitHub ↗
(self, dt)

Source from the content-addressed store, hash-verified

5792 return self.stdoffset + self.dst(dt)
5793
5794 def dst(self, dt):
5795 if dt is None or dt.tzinfo is None:
5796 # An exception instead may be sensible here, in one or more of
5797 # the cases.
5798 return ZERO
5799 assert dt.tzinfo is self
5800
5801 # Find first Sunday in April.
5802 start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
5803 assert start.weekday() == 6 and start.month == 4 and start.day <= 7
5804
5805 # Find last Sunday in October.
5806 end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
5807 assert end.weekday() == 6 and end.month == 10 and end.day >= 25
5808
5809 # Can't compare naive to aware objects, so strip the timezone from
5810 # dt first.
5811 if start <= dt.replace(tzinfo=None) < end:
5812 return HOUR
5813 else:
5814 return ZERO
5815
5816Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
5817Central = USTimeZone(-6, "Central", "CST", "CDT")

Callers 2

tznameMethod · 0.95
utcoffsetMethod · 0.95

Calls 3

first_sunday_on_or_afterFunction · 0.70
replaceMethod · 0.45
weekdayMethod · 0.45

Tested by

no test coverage detected