QDate Class Reference


The QDate class provides date functions. (details) (complete member list)

#include <qdatetm.h>

Public Members

Static Public Members

Static Protected Members

Related Functions

(Note that these are not member functions.)

Detailed Description

The QDate class provides date functions.

The QDate is based on the Gregorian (modern western) calendar. England adopted the Gregorian calendar on September 14th 1752, which is the earliest date that is supported by QDate. Using earlier dates will give undefined results. Some countries adopted the Gregorian calendar later than England, thus the week dat of early dates might be incorrect for these countries (but correct for England). The end of time is reached around 8000AD, by which time we expect Qt to be obsolete.


Member Function Documentation

QDate::QDate ()

Constructs a null date. Null dates are invalid.

QDate::QDate (int y, int m, int d)

Constructs a date with the year y, month m and day d.

QDate QDate::addDays (long ndays) const

Returns this date plus ndays days.

QDate QDate::currentDate ()

Returns the current date.

int QDate::day () const

Returns the day part (1..31) of the date.

See also: year(), month().

const char * QDate::dayName (int weekday) const

Returns the name of the weekday. Weekday 1 == "Mon", day 2 == "Tue" etc.

int QDate::dayOfWeek () const

Returns the weekday (1..7) of the date. Monday is the first day.

int QDate::dayOfYear () const

Returns the day of the year (1..365) of the date.

int QDate::daysInMonth () const

Returns the day of the month (1..31) of the date.

int QDate::daysInYear () const

Returns the number of days in the year (365 or 366).

long QDate::daysTo (const QDate &d) const

Returns the number of days between this date and e:

    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

bool QDate::isNull () const

Returns TRUE if the date is null.

See also: isValid().

bool QDate::isValid () const

Returns TRUE if the date is valid.

See also: isNull().

bool QDate::isValid (int y, int m, int d)

Returns TRUE if the specified date is valid.

bool QDate::leapYear (int y)

Returns TRUE if the specified year y is a leap year.

int QDate::month () const

Returns the month part (1..12) of the date.

See also: year(), day().

const char * QDate::monthName (int month) const

Returns the name of the month. Month 1 == "Jan", month 2 == "Feb" etc.

bool QDate::setYMD (int y, int m, int d)

Sets the year y, month m and day d. Returns TRUE if the date is valid, FALSE if it is invalid.

QString QDate::toString () const

Returns the date as a string. The string format is "Sat May 20 1995".

int QDate::year () const

Returns the year part (>= 1752) of the date.

See also: month(), day().


Related Functions

QDataStream & operator<< (QDataStream &s, const QDate &d)

Writes the date d to the stream s and returns a reference to s.

QDataStream & operator>> (QDataStream &s, QDate &d)

Reads the date d from the stream s and returns a reference to s.


This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 16:17, 1995/06/30 by the webmaster at Troll Tech