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

Method dst

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

Source from the content-addressed store, hash-verified

5605 return self.stdoffset + self.dst(dt)
5606
5607 def dst(self, dt):
5608 if dt is None or dt.tzinfo is None:
5609 # An exception instead may be sensible here, in one or more of
5610 # the cases.
5611 return ZERO
5612 assert dt.tzinfo is self
5613
5614 # Find first Sunday in April.
5615 start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
5616 assert start.weekday() == 6 and start.month == 4 and start.day <= 7
5617
5618 # Find last Sunday in October.
5619 end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
5620 assert end.weekday() == 6 and end.month == 10 and end.day >= 25
5621
5622 # Can't compare naive to aware objects, so strip the timezone from
5623 # dt first.
5624 if start <= dt.replace(tzinfo=None) < end:
5625 return HOUR
5626 else:
5627 return ZERO
5628
5629Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
5630Central = USTimeZone(-6, "Central", "CST", "CDT")

Callers 2

tznameMethod · 0.95
utcoffsetMethod · 0.95

Calls 3

first_sunday_on_or_afterFunction · 0.85
replaceMethod · 0.45
weekdayMethod · 0.45

Tested by

no test coverage detected