⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdate.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
字号:
'\" t.TH QDate 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQDate \- Date functions.PP\fC#include <qdatetime.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "\fBQDate\fR ()".br.ti -1c.BI "\fBQDate\fR ( int y, int m, int d )".br.ti -1c.BI "bool \fBisNull\fR () const".br.ti -1c.BI "bool \fBisValid\fR () const".br.ti -1c.BI "int \fByear\fR () const".br.ti -1c.BI "int \fBmonth\fR () const".br.ti -1c.BI "int \fBday\fR () const".br.ti -1c.BI "int \fBdayOfWeek\fR () const".br.ti -1c.BI "int \fBdayOfYear\fR () const".br.ti -1c.BI "int \fBdaysInMonth\fR () const".br.ti -1c.BI "int \fBdaysInYear\fR () const".br.ti -1c.BI "QString \fBtoString\fR ( Qt::DateFormat f = Qt::TextDate ) const".br.ti -1c.BI "QString \fBtoString\fR ( const QString & format ) const".br.ti -1c.BI "bool \fBsetYMD\fR ( int y, int m, int d )".br.ti -1c.BI "QDate \fBaddDays\fR ( int ndays ) const".br.ti -1c.BI "QDate \fBaddMonths\fR ( int nmonths ) const".br.ti -1c.BI "QDate \fBaddYears\fR ( int nyears ) const".br.ti -1c.BI "int \fBdaysTo\fR ( const QDate & d ) const".br.ti -1c.BI "bool \fBoperator==\fR ( const QDate & d ) const".br.ti -1c.BI "bool \fBoperator!=\fR ( const QDate & d ) const".br.ti -1c.BI "bool \fBoperator<\fR ( const QDate & d ) const".br.ti -1c.BI "bool \fBoperator<=\fR ( const QDate & d ) const".br.ti -1c.BI "bool \fBoperator>\fR ( const QDate & d ) const".br.ti -1c.BI "bool \fBoperator>=\fR ( const QDate & d ) const".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "QString monthName ( int month )  \fI(obsolete)\fR".br.ti -1c.BI "QString dayName ( int weekday )  \fI(obsolete)\fR".br.ti -1c.BI "QString \fBshortMonthName\fR ( int month )".br.ti -1c.BI "QString \fBshortDayName\fR ( int weekday )".br.ti -1c.BI "QString \fBlongMonthName\fR ( int month )".br.ti -1c.BI "QString \fBlongDayName\fR ( int weekday )".br.ti -1c.BI "QDate \fBcurrentDate\fR ()".br.ti -1c.BI "QDate \fBfromString\fR ( const QString & s, Qt::DateFormat f = Qt::TextDate )".br.ti -1c.BI "bool \fBisValid\fR ( int y, int m, int d )".br.ti -1c.BI "bool \fBleapYear\fR ( int y )".br.in -1c.SH RELATED FUNCTION DOCUMENTATION.in +1c.ti -1c.BI "QDataStream & \fBoperator<<\fR ( QDataStream & s, const QDate & d )".br.ti -1c.BI "QDataStream & \fBoperator>>\fR ( QDataStream & s, QDate & d )".br.in -1c.SH DESCRIPTIONThe QDate class provides date functions..PPA 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 dates, e.g. by adding a number of days or months or years..PPA 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 clock's date. An explicit date can also be set using setYMD(). The fromString() function returns a QDate given a string and a date format which is used to interpret the date within the string..PPThe 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..PPQDate provides a full set of operators to compare two QDate objects where smaller means earlier and larger means later..PPYou 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..PPThe daysInMonth() and daysInYear() functions return how many days there are in this date's month and year, respectively. The leapYear() function indicates whether this date is in a leap year..PPNote that QDate should not be used for date calculations for dates prior to the introduction of the Gregorian calendar. This calendar was adopted by England from 14<sup><small>th</small></sup> September 1752 (hence this is the earliest valid QDate), and subsequently by most other western countries, until 1923..PPThe end of time is reached around 8000, by which time we expect Qt to be obsolete..PPSee also QTime, QDateTime, QDateEdit, QDateTimeEdit and Time and Date..SH MEMBER FUNCTION DOCUMENTATION.SH "QDate::QDate ()"Constructs a null date. Null dates are invalid..PPSee also isNull() and isValid()..SH "QDate::QDate ( int y, int m, int d )"Constructs a date with year \fIy\fR, month \fIm\fR and day \fId\fR..PP\fIy\fR must be in the range 1752..8000, \fIm\fR must be in the range 1..12, and \fId\fR must be in the range 1..31. Exception: if \fIy\fR is in the range 0..99, it is interpreted as 1900..1999..PPSee also isValid()..SH "QDate QDate::addDays ( int ndays ) const"Returns a QDate object containing a date \fIndays\fR later than the date of this object (or earlier if \fIndays\fR is negative)..PPSee also daysTo()..SH "QDate QDate::addMonths ( int nmonths ) const"Returns a QDate object containing a date \fInmonths\fR later than the date of this object (or earlier if \fInmonths\fR is negative)..SH "QDate QDate::addYears ( int nyears ) const"Returns a QDate object containing a date \fInyears\fR later than the date of this object (or earlier if \fInyears\fR is negative)..SH "QDate QDate::currentDate ()\fC [static]\fR"Returns the current date, as reported by the system clock..PPSee also QTime::currentTime() and QDateTime::currentDateTime()..PPExample: dclock/dclock.cpp..SH "int QDate::day () const"Returns the day of the month (1..31) of this date..PPSee also year(), month() and dayOfWeek()..PPExample: dclock/dclock.cpp..SH "QString QDate::dayName ( int weekday )\fC [static]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPUse shortDayName() instead..SH "int QDate::dayOfWeek () const"Returns the weekday (Monday=1..Sunday=7) for this date..PPSee also day() and dayOfYear()..SH "int QDate::dayOfYear () const"Returns the day of the year (1..365) for this date..PPSee also day() and dayOfWeek()..SH "int QDate::daysInMonth () const"Returns the number of days in the month (28..31) for this date..PPSee also day() and daysInYear()..SH "int QDate::daysInYear () const"Returns the number of days in the year (365 or 366) for this date..PPSee also day() and daysInMonth()..SH "int QDate::daysTo ( const QDate & d ) const"Returns the number of days from this date to \fId\fR (which is negative if \fId\fR is earlier than this date)..PPExample:.PP.nf.br    QDate d1( 1995, 5, 17 );  // May 17th 1995.br    QDate d2( 1995, 5, 20 );  // May 20th 1995.br    d1.daysTo( d2 );          // returns 3.br    d2.daysTo( d1 );          // returns -3.br.fi.PPSee also addDays()..SH "QDate QDate::fromString ( const QString & s, Qt::DateFormat f = Qt::TextDate )\fC [static]\fR"Returns the QDate represented by the string \fIs\fR, using the format \fIf\fR, or an invalid date if this is not possible..PPQt::LocalDate cannot be used here..PPNote for Qt::TextDate: It is recommended to use the English short month names (e.g. Jan). Localized month names may also be used, but they depend on the user's locale settings..SH "bool QDate::isNull () const"Returns TRUE if the date is null; otherwise returns FALSE. A null date is invalid..PPSee also isValid()..SH "bool QDate::isValid () const"Returns TRUE if this date is valid; otherwise returns FALSE..PPSee also isNull()..SH "bool QDate::isValid ( int y, int m, int d )\fC [static]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns TRUE if the specified date (year \fIy\fR, month \fIm\fR and day \fId\fR) is valid..PPExample:.PP.nf.br    QDate::isValid( 2002, 5, 17 );  // TRUE   May 17th 2002 is valid.br    QDate::isValid( 2002, 2, 30 );  // FALSE  Feb 30th does not exist.br    QDate::isValid( 2004, 2, 29 );  // TRUE   2004 is a leap year.br    QDate::isValid( 1202, 6, 6 );   // FALSE  1202 is pre-Gregorian.br.fi.PPNote that a \fIy\fR value in the range 00..99 is interpreted as 1900..1999..PPSee also isNull() and setYMD()..SH "bool QDate::leapYear ( int y )\fC [static]\fR"Returns TRUE if the specified year \fIy\fR is a leap year..SH "QString QDate::longDayName ( int weekday )\fC [static]\fR"Returns the long name of the \fIweekday\fR..PP1 = "Monday", 2 = "Tuesday", ... 7 = "Sunday".PPThe day names will be localized according to the system's locale settings..PPSee also toString(), shortDayName(), shortMonthName() and longMonthName()..SH "QString QDate::longMonthName ( int month )\fC [static]\fR"Returns the long name of the \fImonth\fR..PP1 = "January", 2 = "February", ... 12 = "December".PPThe month names will be localized according to the system's locale settings..PPSee also toString(), shortMonthName(), shortDayName() and longDayName()..SH "int QDate::month () const"Returns the month (January=1..December=12) of this date..PPSee also year() and day()..PPExample: dclock/dclock.cpp..SH "QString QDate::monthName ( int month )\fC [static]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPUse shortMonthName() instead..SH "bool QDate::operator!= ( const QDate & d ) const"Returns TRUE if this date is different from \fId\fR; otherwise returns FALSE..SH "bool QDate::operator< ( const QDate & d ) const"Returns TRUE if this date is earlier than \fId\fR, otherwise returns FALSE..SH "bool QDate::operator<= ( const QDate & d ) const"Returns TRUE if this date is earlier than or equal to \fId\fR, otherwise returns FALSE..SH "bool QDate::operator== ( const QDate & d ) const"Returns TRUE if this date is equal to \fId\fR; otherwise returns FALSE..SH "bool QDate::operator> ( const QDate & d ) const"Returns TRUE if this date is later than \fId\fR, otherwise returns FALSE..SH "bool QDate::operator>= ( const QDate & d ) const"Returns TRUE if this date is later than or equal to \fId\fR, otherwise returns FALSE..SH "bool QDate::setYMD ( int y, int m, int d )"Sets the date's year \fIy\fR, month \fIm\fR and day \fId\fR..PP\fIy\fR must be in the range 1752..8000, \fIm\fR must be in the range 1..12, and \fId\fR must be in the range 1..31. Exception: if \fIy\fR is in the range 0..99, it is interpreted as 1900..1999..PPReturns TRUE if the date is valid, otherwise returns FALSE..SH "QString QDate::shortDayName ( int weekday )\fC [static]\fR"Returns the name of the \fIweekday\fR..PP1 = "Mon", 2 = "Tue", ... 7 = "Sun".PPThe day names will be localized according to the system's locale settings..PPSee also toString(), shortMonthName(), longMonthName() and longDayName()..SH "QString QDate::shortMonthName ( int month )\fC [static]\fR"Returns the name of the \fImonth\fR..PP1 = "Jan", 2 = "Feb", ... 12 = "Dec".PPThe month names will be localized according to the system's locale settings..PPSee also toString(), longMonthName(), shortDayName() and longDayName()..SH "QString QDate::toString ( const QString & format ) const"Returns the datetime as a string. The \fIformat\fR parameter determines the format of the result string..PPThese expressions may be used:.TP\fId\fR - the day as number without a leading zero (1-31).TP\fIdd\fR - the day as number with a leading zero (01-31).TP\fIddd\fR - the abbrevated day name (Mon - Sun). Uses QDate::shortDayName()..TP\fIdddd\fR - the long day name (Monday - Sunday). Uses QDate::longDayName()..TP\fIM\fR - the month as number without a leading zero (1-12).TP\fIMM\fR - the month as number with a leading zero (01-12).TP\fIMMM\fR - the abbrevated month name (Jan - Dec). Uses QDate::shortMonthName()..TP\fIMMMM\fR - the long month name (January - December). Uses QDate::longMonthName()..TP\fIyy\fR - the year as two digit number (00-99).TP\fIyyyy\fR - the year as four digit number (0000-9999).PPAll other input characters will be ignored..PPExample format Strings (assumed that the QDate is 21. May 2001).TP"dd.MM.yyyy" will result in "21.05.2001".TP"ddd MMMM d yy" will result in "Tue May 21 01".PPSee also QDate::toString() and QTime::toString()..SH "QString QDate::toString ( Qt::DateFormat f = Qt::TextDate ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the date as a string. The \fIf\fR parameter determines the format of the string..PPIf \fIf\fR is Qt::TextDate, the string format is "Sat May 20 1995" (using the shortDayName() and shortMonthName() functions to generate the string)..PPIf \fIf\fR is Qt::ISODate, the string format corresponds to the ISO 8601 specification for representations of dates, which is YYYY-MM-DD where YYYY is the year, MM is the month of the year (between 01 and 12), and DD is the day of the month between 01 and 31..PPIf \fIf\fR is Qt::LocalDate, the string format depends on the locale settings of the system..PPSee also shortDayName() and shortMonthName()..SH "int QDate::year () const"Returns the year (1752..8000) of this date..PPSee also month() and day()..SH RELATED FUNCTION DOCUMENTATION.SH "QDataStream & operator<< ( QDataStream & s, const QDate & d )"Writes the date, \fId\fR, to the data stream, \fIs\fR..PPSee also Format of the QDataStream operators..SH "QDataStream & operator>> ( QDataStream & s, QDate & d )"Reads a date from the stream \fIs\fR into \fId\fR..PPSee also Format of the QDataStream operators..SH "SEE ALSO".BR http://doc.trolltech.com/qdate.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qdate.3qt) and the Qtversion (3.0.0).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -