The QDate class provides date functions. More...
#include <qdatetime.h>
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.
Constructs a null date. Null dates are invalid.
See also isNull() and isValid().
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.
See also isValid().
Returns a QDate object containing a date ndays later than the date of this object (or earlier if ndays is negative).
See also daysTo().
[static]
Returns the current date, as reported by the system clock.
See also QTime::currentTime() and QDateTime::currentDateTime().
Returns the day of the month (1..31) of this date.
See also year(), month() and dayOfWeek().
[virtual]
Returns the name of the weekday.
Weekday 1 == "Mon", day 2 == "Tue" etc.
See also toString() and monthName().
Returns the weekday (Monday=1 .. Sunday=7) for this date.
See also day() and dayOfYear().
Returns the day of the year (1..365) for this date.
See also day() and dayOfWeek().
Returns the number of days in the month (28..31) for this date.
See also day() and daysInYear().
Returns the number of days in the year (365 or 366) for this date.
See also day() and daysInMonth().
Returns the number of days from this date to d (which is negative if d is earlier than this date).
Example:
QDate d1( 1995, 5, 17 ); // May 17th 1995 QDate d2( 1995, 5, 20 ); // May 20th 1995 d1.daysTo( d2 ); // returns 3 d2.daysTo( d1 ); // returns -3
See also addDays().
Returns TRUE if the date is null. A null date is invalid.
See also isValid().
Returns TRUE if this date is valid.
See also isNull().
[static]
Returns TRUE if the specified date (year y, month m and day d) is valid.
Example:
QDate::isValid( 2002, 5, 17 ); // TRUE; May 17th 2002 is OK. QDate::isValid( 2002, 2, 30 ); // FALSE; Feb 30th does not exist QDate::isValid( 2004, 2, 29 ); // TRUE; 2004 is a leap year QDate::isValid( 1202, 6, 6 ); // FALSE; 1202 is pre-Gregorian
Note that a y value in the range 00-99 is interpreted as 1900-1999.
See also isNull() and setYMD().
[static]
Returns TRUE if the specified year y is a leap year.
Returns the month (January=1 .. December=12) of this date.
[virtual]
Returns the name of the month.
Month 1 == "Jan", month 2 == "Feb" etc.
See also toString() and dayName().
Returns TRUE if this date is different from d, or FALSE if they are equal.
Returns TRUE if this date is earlier than d, otherwise FALSE.
Returns TRUE if this date is earlier than or equal to d, otherwise FALSE.
Returns TRUE if this date is equal to d, or FALSE if they are different.
Returns TRUE if this date is later than d, otherwise FALSE.
Returns TRUE if this date is later than or equal to d, otherwise FALSE.
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.
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.
See also dayName() and monthName().
Returns the year (>= 1752) of this date.
[static protected]
For internal use only.
[static protected]
For internal use only.
Writes the date to the stream.
See also Format of the QDataStream operators
Reads a date from the stream.
See also Format of the QDataStream operators
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright İ 2000 Trolltech | Trademarks | Qt version 2.2.1
|