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

Function _ymd2ord

Lib/_pydatetime.py:68–75  ·  view source on GitHub ↗

year, month, day -> ordinal, considering 01-Jan-0001 as day 1.

(year, month, day)

Source from the content-addressed store, hash-verified

66 return _DAYS_BEFORE_MONTH[month] + (month > 2 and _is_leap(year))
67
68def _ymd2ord(year, month, day):
69 "year, month, day -> ordinal, considering 01-Jan-0001 as day 1."
70 assert 1 <= month <= 12, f"month must be in 1..12, not {month}"
71 dim = _days_in_month(year, month)
72 assert 1 <= day <= dim, f"day must be in 1..{dim}, not {day}"
73 return (_days_before_year(year) +
74 _days_before_month(year, month) +
75 day)
76
77_DI400Y = _days_before_year(401) # number of days in 400 years
78_DI100Y = _days_before_year(101) # " " " " 100 "

Callers 6

_build_struct_timeFunction · 0.85
_isoweek_to_gregorianFunction · 0.85
toordinalMethod · 0.85
isocalendarMethod · 0.85
__hash__Method · 0.85
_isoweek1mondayFunction · 0.85

Calls 3

_days_in_monthFunction · 0.85
_days_before_yearFunction · 0.85
_days_before_monthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…