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. (see {QDate G and J} {Use of Gregorian and Julian Calendars} for dates prior to 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. Note that QDate interprets two digit years to be in the 1900s, e.g., 50 will equals 1950. A QDate can also be constructed with the static function currentDate(), which 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 a date is in a leap year.

Definition at line 56 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


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