MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / isocalendar

Method isocalendar

tools/python-3.11.9-amd64/Lib/datetime.py:1171–1197  ·  view source on GitHub ↗

Return a named tuple containing ISO year, week number, and weekday. The first ISO week of the year is the (Mon-Sun) week containing the year's first Thursday; everything else derives from that. The first week is 1; Monday is 1 ... Sunday is 7. ISO c

(self)

Source from the content-addressed store, hash-verified

1169 return self.toordinal() % 7 or 7
1170
1171 def isocalendar(self):
1172 """Return a named tuple containing ISO year, week number, and weekday.
1173
1174 The first ISO week of the year is the (Mon-Sun) week
1175 containing the year's first Thursday; everything else derives
1176 from that.
1177
1178 The first week is 1; Monday is 1 ... Sunday is 7.
1179
1180 ISO calendar algorithm taken from
1181 http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
1182 (used with permission)
1183 """
1184 year = self._year
1185 week1monday = _isoweek1monday(year)
1186 today = _ymd2ord(self._year, self._month, self._day)
1187 # Internally, week and day have origin 0
1188 week, day = divmod(today - week1monday, 7)
1189 if week < 0:
1190 year -= 1
1191 week1monday = _isoweek1monday(year)
1192 week, day = divmod(today - week1monday, 7)
1193 elif week >= 52:
1194 if today >= _isoweek1monday(year+1):
1195 year += 1
1196 week = 0
1197 return _IsoCalendarDate(year, week+1, day+1)
1198
1199 # Pickle support.
1200

Callers

nothing calls this directly

Calls 2

_isoweek1mondayFunction · 0.85
_ymd2ordFunction · 0.85

Tested by

no test coverage detected