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

Class date

Lib/_pydatetime.py:950–1283  ·  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

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