Date¶
- class quantsupport.time.Date(year: int, month: int, day: int)¶
A calendar date, independent of a holiday calendar or time zone.
Date-valued binding inputs accept
Date, an ISOYYYY-MM-DDstring, ordatetime.date. Arithmetic here does not adjust for business days; useCalendarfor holiday-aware operations.Create a valid calendar date.
- Parameters:
year (int) – Calendar year.
month (int) – Month number, from 1 (January) to 12 (December).
day (int) – Day number, starting at 1 and valid for the given month and year.
Methods
- __add__(value: int | Period | str, /) Date¶
- Add calendar days or a tenor without holiday adjustment.
- __sub__(value: Date, /) int¶
- __sub__(value: int | Period | str, /) Date
- Subtract calendar days or a tenor without holiday adjustment.
- advance(n: int, units: TimeUnit | str) Date¶
- Shift the date by calendar units without holiday adjustment.
- Parameters:
n (int) – Signed number of units; negative values move backward.
units (TimeUnit or str) – Calendar unit:
Days,Weeks,Months, orYears, supplied as aTimeUnitor its name.
- Returns:
Shifted calendar date.
- Return type:
- Raises:
QuantSupportValueError – If the date is empty or the offset exceeds the supported date range.
- day_of_year() int¶
- Return the date's ordinal within its calendar year.
- Returns:
One-based day number, from 1 to 365 or 366 in a leap year.
- Return type:
int
- days_in_month() int¶
- Count calendar days in this date's month.
- Returns:
Month length, from 28 to 31 days, accounting for leap years.
- Return type:
int
- end_of_month() Date¶
- Find the last calendar day of this date's month.
- Returns:
Calendar month-end without business-day adjustment; it may be a weekend or holiday.
- Return type:
- is_leap_year() bool¶
- Test whether this date's year is a leap year.
- Returns:
Whether the calendar year contains February 29.
- Return type:
bool
- static parse(s: str, fmt: str = ...) Date¶
Parse a calendar date from formatted text.
- Parameters:
s (str) – Date text matching
fmt.fmt (str, optional) – Chrono
strftimeformat; defaults to"%Y-%m-%d".
- Returns:
Parsed date, without business-day adjustment.
- Return type:
- to_datetime() datetime.date¶
- Convert to the standard Python date type.
- Returns:
Date with the same year, month, and day, without a time or time zone.
- Return type:
datetime.date
- to_str(fmt: str = ...) str¶
- Format the date as text.
- Parameters:
fmt (str, optional) – Chrono
strftimeformat; defaults to"%Y-%m-%d".- Returns:
Date rendered with the requested format.
- Return type:
str
- weekday() str¶
- Return the weekday's English name.
- Returns:
Weekday name, such as
"Monday"or"Thursday".- Return type:
str
Properties
- property day: int¶
Read-only day of the month, starting at 1.
- property month: int¶
Read-only month number, from 1 (January) to 12 (December).
- property year: int¶
Read-only calendar year.