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

Class date

Lib/_pydatetime.py:959–1298  ·  view source on GitHub ↗

Concrete date type. Constructors: __new__() fromtimestamp() today() fromordinal() strptime() Operators: __repr__, __str__ __eq__, __le__, __lt__, __ge__, __gt__, __hash__ __add__, __radd__, __sub__ (add/radd only with timedelta arg) Methods: time

Source from the content-addressed store, hash-verified

957timedelta.resolution = timedelta(microseconds=1)
958
959class date:
960 """Concrete date type.
961
962 Constructors:
963
964 __new__()
965 fromtimestamp()
966 today()
967 fromordinal()
968 strptime()
969
970 Operators:
971
972 __repr__, __str__
973 __eq__, __le__, __lt__, __ge__, __gt__, __hash__
974 __add__, __radd__, __sub__ (add/radd only with timedelta arg)
975
976 Methods:
977
978 timetuple()
979 toordinal()
980 weekday()
981 isoweekday(), isocalendar(), isoformat()
982 ctime()
983 strftime()
984
985 Properties (readonly):
986 year, month, day
987 """
988 __slots__ = '_year', '_month', '_day', '_hashcode'
989
990 def __new__(cls, year, month=None, day=None):
991 """Constructor.
992
993 Arguments:
994
995 year, month, day (required, base 1)
996 """
997 if (month is None and
998 isinstance(year, (bytes, str)) and len(year) == 4 and
999 1 <= ord(year[2:3]) <= 12):
1000 # Pickle support
1001 if isinstance(year, str):
1002 try:
1003 year = year.encode('latin1')
1004 except UnicodeEncodeError:
1005 # More informative error message.
1006 raise ValueError(
1007 "Failed to encode latin1 string when unpickling "
1008 "a date object. "
1009 "pickle.load(data, encoding='latin1') is assumed.")
1010 self = object.__new__(cls)
1011 self.__setstate(year)
1012 self._hashcode = -1
1013 return self
1014 year, month, day = _check_date_fields(year, month, day)
1015 self = object.__new__(cls)
1016 self._year = year

Callers 15

test_strptimeMethod · 0.90
test_more_timetupleMethod · 0.90
test_extractMethod · 0.90
test_combineMethod · 0.90
test_combineMethod · 0.90
test_extractMethod · 0.90
test_utctimetupleMethod · 0.90
ZoneInfoClass · 0.90
test_check_dateMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_strptimeMethod · 0.72
test_more_timetupleMethod · 0.72
test_extractMethod · 0.72
test_combineMethod · 0.72
test_combineMethod · 0.72
test_extractMethod · 0.72
test_utctimetupleMethod · 0.72
test_check_dateMethod · 0.72
test_check_timeMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…