Lines Matching defs:day
25 # both directions. Difference: Dates.py calls January 1 of year 0 day
26 # number 1. The code here calls January 1 of year 1 day number 1. This is
59 "year, month -> number of days in year preceding first day of month."
63 def _ymd2ord(year, month, day):
64 "year, month, day -> ordinal, considering 01-Jan-0001 as day 1."
67 assert 1 <= day <= dim, ('day must be in 1..%d' % dim)
70 day)
76 # A 4-year cycle has an extra leap day over what we'd get from pasting
80 # Similarly, a 400-year cycle has an extra leap day over what we'd get from
84 # OTOH, a 100-year cycle has one fewer leap day than we'd get from
89 "ordinal -> (year, month, day), considering 01-Jan-0001 as day 1."
118 # 100-year cycles precede the desired day, which implies the desired
119 # day is December 31 at the end of a 400-year cycle.
126 # that the desired day is December 31 at the end of the 4-year cycle.
150 # Month and day names. For localized versions, see the calendar module.
356 day = int(dtstr[pos:pos + 2])
358 return [year, month, day]
459 def _isoweek_to_gregorian(year, week, day):
478 if not 0 < day < 8:
479 raise ValueError(f"Invalid weekday: {day} (range is [1, 7])")
482 day_offset = (week - 1) * 7 + (day - 1)
484 # Calculate the ordinal day for monday, week 1
515 def _check_date_fields(year, month, day):
518 day = _index(day)
524 if not 1 <= day <= dim:
525 raise ValueError('day must be in 1..%d' % dim, day)
526 return year, month, day
714 s = ("%d day%s, " % plural(self._days)) + s
919 year, month, day
923 def __new__(cls, year, month=None, day=None):
928 year, month, day (required, base 1)
947 year, month, day = _check_date_fields(year, month, day)
951 self._day = day
973 January 1 of year 1 is day 1. Only the year, month and day are
994 def fromisocalendar(cls, year, week, day):
998 return cls(*_isoweek_to_gregorian(year, week, day))
1072 def day(self):
1073 """day (1-31)"""
1085 """Return proleptic Gregorian ordinal for the year, month and day.
1087 January 1 of year 1 is day 1. Only the year, month and day values
1092 def replace(self, year=None, month=None, day=None):
1098 if day is None:
1099 day = self._day
1100 return type(self)(year, month, day)
1165 "Return day of the week, where Monday == 0 ... Sunday == 6."
1171 "Return day of the week, where Monday == 1 ... Sunday == 7."
1191 # Internally, week and day have origin 0
1192 week, day = divmod(today - week1monday, 7)
1196 week, day = divmod(today - week1monday, 7)
1201 return _IsoCalendarDate(year, week+1, day+1)
1670 """datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
1672 The year, month and day arguments are required. tzinfo may be None, or an
1677 def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0,
1695 year, month, day = _check_date_fields(year, month, day)
1702 self._day = day
1822 return cls(date.year, date.month, date.day,
1866 return _build_struct_time(self.year, self.month, self.day,
1918 y, m, d = self.year, self.month, self.day
1935 def replace(self, year=None, month=None, day=None, hour=None,
1943 if day is None:
1944 day = self.day
1957 return type(self)(year, month, day, hour, minute, second,
2236 days = _ymd2ord(self.year, self.month, self.day)
2286 # Helper to calculate the day number of the Monday starting week 1
2499 # on the day DST starts. We want to return the 1:MM EST spelling because that's