Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QDate Class Reference

List of all members.


Detailed Description

The QDate class provides date functions.

A QDate object contains a calendar date, i.e. year, month, and day numbers, in the Gregorian calendar (Julian calendar for dates before 15 October 1582). It can read the current date from the system clock. It provides functions for comparing dates, and for manipulating dates. For example, it is possible to add and subtract days, months, and years to dates.

A QDate object is typically created either by giving the year, month, and day numbers explicitly, or by using the static function currentDate() that creates a QDate object containing the system clock's date. An explicit date can also be set using setDate(). The fromString() function returns a QDate given a string and a date format which is used to interpret the date within the string.

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(), shortDayName(), longDayName(), shortMonthName(), and longMonthName() functions.

QDate provides a full set of operators to compare two QDate objects where smaller means earlier, and larger means later.

You can increment (or decrement) a date by a given number of days using addDays(). Similarly you can use addMonths() and addYears(). The daysTo() function returns the number of days between two dates.

The daysInMonth() and daysInYear() functions return how many days there are in this date's month and year, respectively. The isLeapYear() function indicates whether this date is in a leap year.

Note that the Gregorian calendar was introduced at different dates in different countries and regions. QDate uses the Gregorian calendar starting from 15 October 1582, and uses the Julian calendar for dates up to 4 October 1582.

See also:
QTime, QDateTime, QDateEdit, QDateTimeEdit, QCalendarWidget

Definition at line 49 of file qdatetime.h.


Public Member Functions

QDate addDays (int days) const
QDate addMonths (int months) const
QDate addYears (int years) const
int day () const
int dayOfWeek () const
int dayOfYear () const
int daysInMonth () const
int daysInYear () const
int daysTo (const QDate &) const
bool isNull () const
bool isValid () const
int month () const
bool operator!= (const QDate &other) const
bool operator< (const QDate &other) const
bool operator<= (const QDate &other) const
bool operator== (const QDate &other) const
bool operator> (const QDate &other) const
bool operator>= (const QDate &other) const
 QDate (int y, int m, int d)
 QDate ()
bool setDate (int year, int month, int date)
bool setYMD (int y, int m, int d)
int toJulianDay () const
QString toString (const QString &format) const
QString toString (Qt::DateFormat f=Qt::TextDate) const
int weekNumber (int *yearNum=0) const
int year () const

Static Public Member Functions

static QDate currentDate ()
static QDate fromJulianDay (int jd)
static QDate fromString (const QString &s, const QString &format)
static QDate fromString (const QString &s, Qt::DateFormat f=Qt::TextDate)
static uint gregorianToJulian (int y, int m, int d)
static bool isLeapYear (int year)
static bool isValid (int y, int m, int d)
static void julianToGregorian (uint jd, int &y, int &m, int &d)
static QString longDayName (int weekday)
static QString longMonthName (int month)
static QString shortDayName (int weekday)
static QString shortMonthName (int month)

Private Attributes

uint jd

Friends

Q_CORE_EXPORT QDataStreamoperator<< (QDataStream &, const QDate &)
Q_CORE_EXPORT QDataStreamoperator>> (QDataStream &, QDate &)
class QDateTime
class QDateTimePrivate

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index