class date – Represent a date
date
objects support equality and comparison operators.
- class datetime.date(year, month, day)
All arguments are required. Arguments must be integers, in the following ranges:
Other constructors:
- classmethod today()
- classmethod fromtimestamp(timestamp)
- classmethod fromordinal(ordinal)
- classmethod fromisoformate(date_string)
Class attributes:
- resolution
The smallest possible difference between non-equal date objects,
timedelta(days=1)
.
Instance attributes:
- year
- month
- day
Instance methods
- replace(year=self.year, month=self.month, day=self.day)
Return a new
date
object with the same values but the specified parameters updated.
- tuple()
Return the date as a tuple (year, month, day)
- timetuple()
Return the date as a 9-tuple
- toordinal()
Return an integer representing the ordinal of the date, where January 1st of year 1 has ordinal 1.
- isoformat()
Return a string representing the date in ISO 8601 format, YYYY-MM-DD:
from datetime import date date(2002, 12, 4).isoformat() # outputs '2002-12-04'
- isoweekday()
Return the day of the week as an integer, where Monday is 1 and Sunday is 7.
- weekday()
Return the day of the week as an integer, where Monday is 0 and Sunday is 6.