A class for manipulating dates.
NOTE: this class is retained only for compatibility, and has been replaced by wxDateTime. wxDate may be withdrawn in future versions of wxWindows.
Derived from
Include files
<wx/date.h>
See also
Members
wxDate::wxDate
wxDate::~wxDate
wxDate::AddMonths
wxDate::AddWeeks
wxDate::AddYears
wxDate::FormatDate
wxDate::GetDay
wxDate::GetDayOfWeek
wxDate::GetDayOfWeekName
wxDate::GetDayOfYear
wxDate::GetDaysInMonth
wxDate::GetFirstDayOfMonth
wxDate::GetJulianDate
wxDate::GetMonth
wxDate::GetMonthEnd
wxDate::GetMonthName
wxDate::GetMonthStart
wxDate::GetWeekOfMonth
wxDate::GetWeekOfYear
wxDate::GetYear
wxDate::GetYearEnd
wxDate::GetYearStart
wxDate::IsLeapYear
wxDate::Set
wxDate::SetFormat
wxDate::SetOption
wxDate::operator wxString
wxDate::operator +
wxDate::operator -
wxDate::operator +=
wxDate::operator -=
wxDate::operator ++
wxDate::operator --
wxDate::operator <
wxDate::operator <=
wxDate::operator >
wxDate::operator >=
wxDate::operator ==
wxDate::operator !=
wxDate::operator <<
wxDate()
Default constructor.
wxDate(const wxDate& date)
Copy constructor.
wxDate(int month, int day, int year)
Constructor taking month, day and year.
wxDate(long julian)
Constructor taking an integer representing the Julian date. This is the number of days since 1st January 4713 B.C., so to convert from the number of days since 1st January 1901, construct a date for 1/1/1901, and add the number of days.
wxDate(const wxString& dateString)
Constructor taking a string representing a date. This must be either the string TODAY, or of the form MM/DD/YYYY or MM-DD-YYYY. For example:
wxDate date("11/26/1966");Parameters
date
month
day
year
void ~wxDate()
Destructor.
wxDate& AddMonths(int months=1)
Adds the given number of months to the date, returning a reference to 'this'.
wxDate& AddWeeks(int weeks=1)
Adds the given number of weeks to the date, returning a reference to 'this'.
wxDate& AddYears(int years=1)
Adds the given number of months to the date, returning a reference to 'this'.
wxString FormatDate(int type=-1) const
Formats the date according to type if not -1, or according to the current display type if -1.
Parameters
type
wxDAY | Format day only. |
wxMONTH | Format month only. |
wxMDY | Format MONTH, DAY, YEAR. |
wxFULL | Format day, month and year in US style: DAYOFWEEK, MONTH, DAY, YEAR. |
wxEUROPEAN | Format day, month and year in European style: DAY, MONTH, YEAR. |
int GetDay() const
Returns the numeric day (in the range 1 to 31).
int GetDayOfWeek() const
Returns the integer day of the week (in the range 1 to 7).
wxString GetDayOfWeekName() const
Returns the name of the day of week.
long GetDayOfYear() const
Returns the day of the year (from 1 to 365).
int GetDaysInMonth() const
Returns the number of days in the month (in the range 1 to 31).
int GetFirstDayOfMonth() const
Returns the day of week that is first in the month (in the range 1 to 7).
long GetJulianDate() const
Returns the Julian date.
int GetMonth() const
Returns the month number (in the range 1 to 12).
wxDate GetMonthEnd()
Returns the date representing the last day of the month.
wxString GetMonthName() const
Returns the name of the month. Do not delete the returned storage.
wxDate GetMonthStart() const
Returns the date representing the first day of the month.
int GetWeekOfMonth() const
Returns the week of month (in the range 1 to 6).
int GetWeekOfYear() const
Returns the week of year (in the range 1 to 52).
int GetYear() const
Returns the year as an integer (such as '1995').
wxDate GetYearEnd() const
Returns the date representing the last day of the year.
wxDate GetYearStart() const
Returns the date representing the first day of the year.
bool IsLeapYear() const
Returns TRUE if the year of this date is a leap year.
wxDate& Set()
Sets the date to current system date, returning a reference to 'this'.
wxDate& Set(long julian)
Sets the date to the given Julian date, returning a reference to 'this'.
wxDate& Set(int month, int day, int year)
Sets the date to the given date, returning a reference to 'this'.
month is a number from 1 to 12.
day is a number from 1 to 31.
year is a year, such as 1995, 2005.
void SetFormat(int format)
Sets the current format type.
Parameters
format
wxDAY | Format day only. |
wxMONTH | Format month only. |
wxMDY | Format MONTH, DAY, YEAR. |
wxFULL | Format day, month and year in US style: DAYOFWEEK, MONTH, DAY, YEAR. |
wxEUROPEAN | Format day, month and year in European style: DAY, MONTH, YEAR. |
int SetOption(int option, const bool enable=TRUE)
Enables or disables an option for formatting.
Parameters
option
wxNO_CENTURY | The century is not formatted. |
wxDATE_ABBR | Month and day names are abbreviated to 3 characters when formatting. |
operator wxString()
Conversion operator, to convert wxDate to wxString by calling FormatDate.
wxDate operator +(long i)
wxDate operator +(int i)
Adds an integer number of days to the date, returning a date.
wxDate operator -(long i)
wxDate operator -(int i)
Subtracts an integer number of days from the date, returning a date.
long operator -(const wxDate& date)
Subtracts one date from another, return the number of intervening days.
wxDate& operator +=(long i)
Postfix operator: adds an integer number of days to the date, returning a reference to 'this' date.
wxDate& operator -=(long i)
Postfix operator: subtracts an integer number of days from the date, returning a reference to 'this' date.
wxDate& operator ++()
Increments the date (postfix or prefix).
wxDate& operator --()
Decrements the date (postfix or prefix).
friend bool operator <(const wxDate& date1, const wxDate& date2)
Function to compare two dates, returning TRUE if date1 is earlier than date2.
friend bool operator <=(const wxDate& date1, const wxDate& date2)
Function to compare two dates, returning TRUE if date1 is earlier than or equal to date2.
friend bool operator >(const wxDate& date1, const wxDate& date2)
Function to compare two dates, returning TRUE if date1 is later than date2.
friend bool operator >=(const wxDate& date1, const wxDate& date2)
Function to compare two dates, returning TRUE if date1 is later than or equal to date2.
friend bool operator ==(const wxDate& date1, const wxDate& date2)
Function to compare two dates, returning TRUE if date1 is equal to date2.
friend bool operator !=(const wxDate& date1, const wxDate& date2)
Function to compare two dates, returning TRUE if date1 is not equal to date2.
friend ostream& operator <<(ostream& os, const wxDate& date)
Function to output a wxDate to an ostream.