|
ISLEman
|
The QDate class provides date functions. More...
#include <qdatetime.h>
Public Member Functions | |
| QDate () | |
| QDate (int y, int m, int d) | |
| bool | isNull () const |
| bool | isValid () const |
| int | year () const |
| int | month () const |
| int | day () const |
| int | dayOfWeek () const |
| int | dayOfYear () const |
| int | daysInMonth () const |
| int | daysInYear () const |
| virtual QString | monthName (int month) const |
| virtual QString | dayName (int weekday) const |
| QString | toString () const |
| bool | setYMD (int y, int m, int d) |
| QDate | addDays (int days) const |
| int | daysTo (const QDate &) const |
| bool | operator== (const QDate &d) const |
| bool | operator!= (const QDate &d) const |
| bool | operator< (const QDate &d) const |
| bool | operator<= (const QDate &d) const |
| bool | operator> (const QDate &d) const |
| bool | operator>= (const QDate &d) const |
Static Public Member Functions | |
| static QDate | currentDate () |
| static bool | isValid (int y, int m, int d) |
| static bool | leapYear (int year) |
Static Protected Member Functions | |
| static uint | greg2jul (int y, int m, int d) |
| static void | jul2greg (uint jd, int &y, int &m, int &d) |
Friends | |
| class | QDateTime |
| Q_EXPORT QDataStream & | operator<< (QDataStream &, const QDate &) |
| Q_EXPORT QDataStream & | operator>> (QDataStream &, QDate &) |
The QDate class provides date functions.
A QDate object contains a calendar date, i.e. year, month, and day numbers in the modern western (Gregorian) calendar. It can read the current date from the system clock. It provides functions for comparing dates and for manipulating a date by adding a number of days.
A QDate object is typically created either by giving the year, month and day numbers explicitly, or by using the static function currentDate(), which makes a QDate object which contains the system's clock date. An explicit date can also be set using setYMD().
The year(), month(), and day() functions provide access to the year, month, and day numbers. Also, dayOfWeek() and dayOfYear() functions are provided. The same information is provided in textual format by the toString(), dayName(), and monthName() functions.
QDate provides a full set of operators to compare two QDate objects. A date is considered smaller than another if it is earlier than the other.
The date a given number of days later than a given date can be found using the addDays() function. Correspondingly, the number of days between two dates can be found using the daysTo() function.
The daysInMonth() and daysInYear() functions tell how many days there are in this date's month and year, respectively. The isLeapYear() function tells whether this date is in a leap year.
Note that QDate may not be used for date calculations for dates in the remote past, i.e. prior to the introduction of the Gregorian calendar. This calendar was adopted by England Sep. 14. 1752 (hence this is the earliest valid QDate), and subsequently by most other western countries, until 1923.
The end of time is reached around 8000AD, by which time we expect Qt to be obsolete.
| QDate::QDate | ( | int | y, |
| int | m, | ||
| int | d | ||
| ) |
Constructs a date with the year y, month m and day d.
y must be in the range 1752-ca. 8000, m must be in the range 1-12, and d must be in the range 1-31. Exception: if y is in the range 0-99, it is interpreted as 1900-1999.
| QDate QDate::addDays | ( | int | ndays | ) | const |
|
static |
Returns the current date, as reported by the system clock.
| int QDate::day | ( | ) | const |
Returns the day of the month (1..31) of this date.
|
virtual |
Returns the name of the weekday.
Weekday 1 == "Mon", day 2 == "Tue" etc.
| int QDate::dayOfWeek | ( | ) | const |
Returns the weekday (Monday=1 .. Sunday=7) for this date.
| int QDate::dayOfYear | ( | ) | const |
Returns the day of the year (1..365) for this date.
| int QDate::daysInMonth | ( | ) | const |
Returns the number of days in the month (28..31) for this date.
| int QDate::daysInYear | ( | ) | const |
Returns the number of days in the year (365 or 366) for this date.
| int QDate::daysTo | ( | const QDate & | d | ) | const |
|
inline |
Returns TRUE if the date is null. A null date is invalid.
| bool QDate::isValid | ( | ) | const |
Returns TRUE if this date is valid.
|
static |
Returns TRUE if the specified date (year y, month m and day d) is valid.
Note that a y value in the range 00-99 is interpreted as 1900-1999.
|
static |
Returns TRUE if the specified year y is a leap year.
| int QDate::month | ( | ) | const |
|
virtual |
Returns the name of the month.
Month 1 == "Jan", month 2 == "Feb" etc.
|
inline |
Returns TRUE if this date is different from d, or FALSE if they are equal.
|
inline |
Returns TRUE if this date is earlier than d, otherwise FALSE.
|
inline |
Returns TRUE if this date is earlier than or equal to d, otherwise FALSE.
|
inline |
Returns TRUE if this date is equal to d, or FALSE if they are different.
|
inline |
Returns TRUE if this date is later than d, otherwise FALSE.
|
inline |
Returns TRUE if this date is later than or equal to d, otherwise FALSE.
| bool QDate::setYMD | ( | int | y, |
| int | m, | ||
| int | d | ||
| ) |
Sets the year y, month m and day d.
y must be in the range 1752-ca. 8000, m must be in the range 1-12, and d must be in the range 1-31. Exception: if y is in the range 0-99, it is interpreted as 1900-1999.
Returns TRUE if the date is valid, otherwise FALSE.
| QString QDate::toString | ( | ) | const |
Returns the date as a string.
The string format is "Sat May 20 1995". This function uses the dayName() and monthName() functions to generate the string.
|
friend |
Writes the date to the stream.
|
friend |
Reads a date from the stream.
1.8.12