Concrete date type. Constructors: __new__() fromtimestamp() today() fromordinal() Operators: __repr__, __str__ __eq__, __le__, __lt__, __ge__, __gt__, __hash__ __add__, __radd__, __sub__ (add/radd only with timedelta arg) Methods: ti
| 891 | timedelta.resolution = timedelta(microseconds=1) |
| 892 | |
| 893 | class date: |
| 894 | """Concrete date type. |
| 895 | |
| 896 | Constructors: |
| 897 | |
| 898 | __new__() |
| 899 | fromtimestamp() |
| 900 | today() |
| 901 | fromordinal() |
| 902 | |
| 903 | Operators: |
| 904 | |
| 905 | __repr__, __str__ |
| 906 | __eq__, __le__, __lt__, __ge__, __gt__, __hash__ |
| 907 | __add__, __radd__, __sub__ (add/radd only with timedelta arg) |
| 908 | |
| 909 | Methods: |
| 910 | |
| 911 | timetuple() |
| 912 | toordinal() |
| 913 | weekday() |
| 914 | isoweekday(), isocalendar(), isoformat() |
| 915 | ctime() |
| 916 | strftime() |
| 917 | |
| 918 | Properties (readonly): |
| 919 | year, month, day |
| 920 | """ |
| 921 | __slots__ = '_year', '_month', '_day', '_hashcode' |
| 922 | |
| 923 | def __new__(cls, year, month=None, day=None): |
| 924 | """Constructor. |
| 925 | |
| 926 | Arguments: |
| 927 | |
| 928 | year, month, day (required, base 1) |
| 929 | """ |
| 930 | if (month is None and |
| 931 | isinstance(year, (bytes, str)) and len(year) == 4 and |
| 932 | 1 <= ord(year[2:3]) <= 12): |
| 933 | # Pickle support |
| 934 | if isinstance(year, str): |
| 935 | try: |
| 936 | year = year.encode('latin1') |
| 937 | except UnicodeEncodeError: |
| 938 | # More informative error message. |
| 939 | raise ValueError( |
| 940 | "Failed to encode latin1 string when unpickling " |
| 941 | "a date object. " |
| 942 | "pickle.load(data, encoding='latin1') is assumed.") |
| 943 | self = object.__new__(cls) |
| 944 | self.__setstate(year) |
| 945 | self._hashcode = -1 |
| 946 | return self |
| 947 | year, month, day = _check_date_fields(year, month, day) |
| 948 | self = object.__new__(cls) |
| 949 | self._year = year |
| 950 | self._month = month |
no outgoing calls
no test coverage detected