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
| 957 | timedelta.resolution = timedelta(microseconds=1) |
| 958 | |
| 959 | class 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 |
no outgoing calls
searching dependent graphs…