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 ISO YYYY-MM-DD string, or datetime.date. Arithmetic here does not adjust for business days; use Calendar for 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.

Source declaration

Methods

__add__(value: int | Period | str, /) → Date
Add calendar days or a tenor without holiday adjustment.
Parameters:

value (int, Period, or str) – Signed calendar-day count or interval such as "6M".

Returns:

Shifted date.

Return type:

Date

__sub__(value: Date, /) → int
__sub__(value: int | Period | str, /) → Date
Subtract calendar days or a tenor without holiday adjustment.
Parameters:

value (int, Period, or str) – Signed calendar-day count or interval such as "6M".

Returns:

Shifted date.

Return type:

Date

add_period(period: Period | str) → Date
Add a tenor without business-day adjustment.
Parameters:

period (Period or str) – Calendar interval, as a Period or tenor string such as "6M" or "1Y6M".

Returns:

Date after adding the interval.

Return type:

Date

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, or Years, supplied as a TimeUnit or its name.

Returns:

Shifted calendar date.

Return type:

Date

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:

Date

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 strftime format; defaults to "%Y-%m-%d".

Returns:

Parsed date, without business-day adjustment.

Return type:

Date

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 strftime format; 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.