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

Class datetime

Lib/_pydatetime.py:1746–2382  ·  view source on GitHub ↗

datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]]) The year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.

Source from the content-addressed store, hash-verified

1744
1745
1746class datetime(date):
1747 """datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
1748
1749 The year, month and day arguments are required. tzinfo may be None, or an
1750 instance of a tzinfo subclass. The remaining arguments may be ints.
1751 """
1752 __slots__ = time.__slots__
1753
1754 def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0,
1755 microsecond=0, tzinfo=None, *, fold=0):
1756 if (isinstance(year, (bytes, str)) and len(year) == 10 and
1757 1 <= ord(year[2:3])&0x7F <= 12):
1758 # Pickle support
1759 if isinstance(year, str):
1760 try:
1761 year = bytes(year, 'latin1')
1762 except UnicodeEncodeError:
1763 # More informative error message.
1764 raise ValueError(
1765 "Failed to encode latin1 string when unpickling "
1766 "a datetime object. "
1767 "pickle.load(data, encoding='latin1') is assumed.")
1768 self = object.__new__(cls)
1769 self.__setstate(year, month)
1770 self._hashcode = -1
1771 return self
1772 year, month, day = _check_date_fields(year, month, day)
1773 hour, minute, second, microsecond, fold = _check_time_fields(
1774 hour, minute, second, microsecond, fold)
1775 _check_tzinfo_arg(tzinfo)
1776 self = object.__new__(cls)
1777 self._year = year
1778 self._month = month
1779 self._day = day
1780 self._hour = hour
1781 self._minute = minute
1782 self._second = second
1783 self._microsecond = microsecond
1784 self._tzinfo = tzinfo
1785 self._hashcode = -1
1786 self._fold = fold
1787 return self
1788
1789 # Read-only field accessors
1790 @property
1791 def hour(self):
1792 """hour (0-23)"""
1793 return self._hour
1794
1795 @property
1796 def minute(self):
1797 """minute (0-59)"""
1798 return self._minute
1799
1800 @property
1801 def second(self):
1802 """second (0-59)"""
1803 return self._second

Callers 15

Time2InternaldateFunction · 0.90
datetimetester.pyFile · 0.90
test_issue23600Method · 0.90
setUpMethod · 0.90
test_aware_datetimeMethod · 0.90
test_zonesMethod · 0.90
test_combineMethod · 0.90
test_mixed_compareMethod · 0.90
_utc_foldMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_issue23600Method · 0.72
setUpMethod · 0.72
test_aware_datetimeMethod · 0.72
test_zonesMethod · 0.72
test_combineMethod · 0.72
test_mixed_compareMethod · 0.72
_utc_foldMethod · 0.72
_loc_foldMethod · 0.72