QCalendar¶
New in version 5.14.
Synopsis¶
Functions¶
def
dateFromParts
(parts)def
dateFromParts
(year, month, day)def
dayOfWeek
(date)def
daysInMonth
(month[, year=Unspecified])def
daysInYear
(year)def
hasYearZero
()def
isDateValid
(year, month, day)def
isGregorian
()def
isLeapYear
(year)def
isLunar
()def
isLuniSolar
()def
isProleptic
()def
isSolar
()def
isValid
()def
maximumDaysInMonth
()def
maximumMonthsInYear
()def
minimumDaysInMonth
()def
monthName
(locale, month[, year=Unspecified[, format=QLocale.LongFormat]])def
monthsInYear
(year)def
name
()def
partsFromDate
(date)def
standaloneMonthName
(locale, month[, year=Unspecified[, format=QLocale.LongFormat]])def
standaloneWeekDayName
(locale, day[, format=QLocale.LongFormat])def
weekDayName
(locale, day[, format=QLocale.LongFormat])
Static functions¶
def
availableCalendars
()
Detailed Description¶
A
QCalendar
object maps a year, month, and day-number to a specific day (ultimately identified by its Julian day number), using the rules of a particular system.The default
QCalendar()
is a proleptic Gregorian calendar, which has no year zero. Other calendars may be supported by enabling suitable features or loading plugins. Calendars supported as features can be constructed by passing theSystem
enumeration to the constructor. All supported calendars may be constructed by name, once they have been constructed. (Thus plugins instantiate their calendar backend to register it.) Built-in backends, accessible viaSystem
, are also always available by name.A
QCalendar
value is immutable.
- PySide2.QtCore.QCalendar.System¶
This enumerated type is used to specify a choice of calendar system.
Constant
Description
QCalendar.System.Gregorian
The default calendar, used internationally.
QCalendar.System.Julian
An ancient Roman calendar.
QCalendar.System.Milankovic
A revised Julian calendar used by some Orthodox churches.
QCalendar.System.Jalali
The Solar Hijri calendar (also called Persian).
QCalendar.System.IslamicCivil
The (tabular) Islamic Civil calendar.
See also
- static PySide2.QtCore.QCalendar.availableCalendars()¶
- Return type:
list of strings
Returns a list of names of the available calendar systems.
These may be supplied by plugins or other code linked into an application, in addition to the ones provided by Qt, some of which are controlled by features.
- PySide2.QtCore.QCalendar.dateFromParts(parts)¶
- Parameters:
- Return type:
- PySide2.QtCore.QCalendar.dateFromParts(year, month, day)
- Parameters:
year – int
month – int
day – int
- Return type:
- PySide2.QtCore.QCalendar.dayOfWeek(date)¶
- Parameters:
date –
PySide2.QtCore.QDate
- Return type:
int
Returns the day of the week number for the given
date
.Returns zero if the calendar is unable to represent the indicated date. Returns 1 for Monday through 7 for Sunday. Calendars with intercallary days may use other numbers to represent these.
See also
partsFromDate()
DayOfWeek
- PySide2.QtCore.QCalendar.daysInMonth(month[, year=Unspecified])¶
- Parameters:
month – int
year – int
- Return type:
int
Returns the number of days in the given
month
of the givenyear
.Months are numbered consecutively, starting with 1 for the first month of each year. If
year
isUnspecified
(its default, if not passed), the month’s length in a normal year is returned.See also
- PySide2.QtCore.QCalendar.daysInYear(year)¶
- Parameters:
year – int
- Return type:
int
Returns the number of days in the given
year
.Handling of
Unspecified
asyear
is undefined.
- PySide2.QtCore.QCalendar.hasYearZero()¶
- Return type:
bool
Returns
true
if this calendar has a year zero.A calendar may represent years from its first year onwards but provide no way to describe years before its first; such a calendar has no year zero and is not proleptic.
A calendar which represents years before its first may number these years simply by following the usual integer counting, so that the year before the first is year zero, with negative-numbered years preceding this; such a calendar is proleptic and has a year zero. A calendar might also have a year zero (for example, the year of some great event, with subsequent years being the first year after that event, the second year after, and so on) without describing years before its year zero. Such a calendar would have a year zero without being proleptic.
Some calendars, however, represent years before their first by an alternate numbering; for example, the proleptic Gregorian calendar’s first year is 1 CE and the year before it is 1 BCE, preceded by 2 BCE and so on. In this case, we use negative year numbers for this alternate numbering, with year -1 as the year before year 1, year -2 as the year before year -1 and so on. Such a calendar is proleptic but has no year zero.
See also
- PySide2.QtCore.QCalendar.isDateValid(year, month, day)¶
- Parameters:
year – int
month – int
day – int
- Return type:
bool
Returns
true
precisely if the givenyear
,month
, andday
specify a valid date in this calendar.Usually this means 1 <= month <=
monthsInYear
(year) and 1 <= day <=daysInMonth
(month, year). However, calendars with intercallary days or months may complicate that.
- PySide2.QtCore.QCalendar.isGregorian()¶
- Return type:
bool
Returns
true
if this calendar object is the Gregorian calendar object used as default calendar by other Qt APIs, e.g. inQDate
.
- PySide2.QtCore.QCalendar.isLeapYear(year)¶
- Parameters:
year – int
- Return type:
bool
Returns
true
if the givenyear
is a leap year.Since the year is not a whole number of days long, some years are longer than others. The difference may be a whole month or just a single day; the details vary between calendars.
See also
- PySide2.QtCore.QCalendar.isLunar()¶
- Return type:
bool
Returns
true
if this calendar is a lunar calendar.A lunar calendar is one based primarily on the phases of the moon.
- PySide2.QtCore.QCalendar.isLuniSolar()¶
- Return type:
bool
Returns
true
if this calendar is luni-solar.A luni-solar calendar expresses the phases of the moon but adapts itself to also keep track of the Sun’s varying position in the sky, relative to the fixed stars.
- PySide2.QtCore.QCalendar.isProleptic()¶
- Return type:
bool
Returns
true
if this calendar is proleptic.A proleptic calendar is able to describe years arbitrarily long before its first. These are represented by negative year numbers and possibly by a year zero.
See also
- PySide2.QtCore.QCalendar.isSolar()¶
- Return type:
bool
Returns
true
if this calendar is solar.A solar calendar is based primarily on the Sun’s varying position in the sky, relative to the fixed stars.
- PySide2.QtCore.QCalendar.isValid()¶
- Return type:
bool
Returns true if this is a valid calendar object.
Constructing a calendar with an unrecognised calendar name may result in an invalid object. Use this method to check after creating a calendar by name.
- PySide2.QtCore.QCalendar.maximumDaysInMonth()¶
- Return type:
int
Returns the number of days in the longest month in the calendar, in any year.
See also
- PySide2.QtCore.QCalendar.maximumMonthsInYear()¶
- Return type:
int
Returns the largest number of months that any year may contain.
- PySide2.QtCore.QCalendar.minimumDaysInMonth()¶
- Return type:
int
Returns the number of days in the shortest month in the calendar, in any year.
See also
- PySide2.QtCore.QCalendar.monthName(locale, month[, year=Unspecified[, format=QLocale.LongFormat]])¶
- Parameters:
locale –
PySide2.QtCore.QLocale
month – int
year – int
format –
FormatType
- Return type:
str
Returns a suitably localised name for a month.
The month is indicated by a number, with
month
= 1 meaning the first month of the year and subsequent months numbered accordingly. Returns an empty string if themonth
number is unrecognized.The
year
may be Unspecified, in which case the mapping from numbers to names for a typical year’s months should be used. Some calendars have leap months that aren’t always at the end of the year; their mapping of month numbers to names may then depend on the placement of a leap month. Thus the year should normally be specified, if known.The name is returned in the form that would normally be used in a full date, in the specified
locale
; theformat
determines how fully it shall be expressed (i.e. to what extent it is abbreviated).See also
standaloneMonthName()
maximumMonthsInYear()
dateTimeToString()
- PySide2.QtCore.QCalendar.monthsInYear(year)¶
- Parameters:
year – int
- Return type:
int
Returns the number of months in the given
year
.If
year
isUnspecified
, returns the maximum number of months in a year.See also
- PySide2.QtCore.QCalendar.name()¶
- Return type:
str
The primary name of this calendar.
- PySide2.QtCore.QCalendar.partsFromDate(date)¶
- Parameters:
date –
PySide2.QtCore.QDate
- Return type:
Converts a
QDate
to a year, month, and day of the month.The returned structure’s
isValid()
shall be false if the calendar is unable to represent the givendate
. Otherwise its year, month, and day members record the so-named parts of its representation.See also
- PySide2.QtCore.QCalendar.standaloneMonthName(locale, month[, year=Unspecified[, format=QLocale.LongFormat]])¶
- Parameters:
locale –
PySide2.QtCore.QLocale
month – int
year – int
format –
FormatType
- Return type:
str
Returns a suitably localised standalone name for a month.
The month is indicated by a number, with
month
= 1 meaning the first month of the year and subsequent months numbered accordingly. Returns an empty string if themonth
number is unrecognized.The
year
may be Unspecified, in which case the mapping from numbers to names for a typical year’s months should be used. Some calendars have leap months that aren’t always at the end of the year; their mapping of month numbers to names may then depend on the placement of a leap month. Thus the year should normally be specified, if known.The name is returned in the form that would be used in isolation in the specified
locale
; theformat
determines how fully it shall be expressed (i.e. to what extent it is abbreviated).See also
monthName()
maximumMonthsInYear()
dateTimeToString()
- PySide2.QtCore.QCalendar.standaloneWeekDayName(locale, day[, format=QLocale.LongFormat])¶
- Parameters:
locale –
PySide2.QtCore.QLocale
day – int
format –
FormatType
- Return type:
str
Returns a suitably localised standalone name for a day of the week.
The days of the week are numbered from 1 for Monday through 7 for Sunday. Some calendars may support higher numbers for other days (e.g. intercallary days, that are not part of any week). Returns an empty string if the
day
number is unrecognized.The name is returned in the form that would be used in isolation (for example as a column heading in a calendar’s tabular display of a month with successive weeks as rows) in the specified
locale
; theformat
determines how fully it shall be expressed (i.e. to what extent it is abbreviated).See also
- PySide2.QtCore.QCalendar.weekDayName(locale, day[, format=QLocale.LongFormat])¶
- Parameters:
locale –
PySide2.QtCore.QLocale
day – int
format –
FormatType
- Return type:
str
Returns a suitably localised name for a day of the week.
The days of the week are numbered from 1 for Monday through 7 for Sunday. Some calendars may support higher numbers for other days (e.g. intercallary days, that are not part of any week). Returns an empty string if the
day
number is unrecognized.The name is returned in the form that would normally be used in a full date, in the specified
locale
; theformat
determines how fully it shall be expressed (i.e. to what extent it is abbreviated).See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.