## wxDate

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

wxObject

Include files

<wx/date.h>

See also

wxTime

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::wxDate

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

Date to copy.

month

Month: a number between 1 and 12.

day

Day: a number between 1 and 31.

year

Year, such as 1995, 2005.

### wxDate::~wxDate

void ~wxDate()

Destructor.

### wxDate::AddMonths

wxDate& AddMonths(int months=1)

Adds the given number of months to the date, returning a reference to 'this'.

### wxDate::AddWeeks

wxDate& AddWeeks(int weeks=1)

Adds the given number of weeks to the date, returning a reference to 'this'.

### wxDate::AddYears

wxDate& AddYears(int years=1)

Adds the given number of months to the date, returning a reference to 'this'.

### wxDate::FormatDate

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

-1 or one of:

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.

### wxDate::GetDay

int GetDay() const

Returns the numeric day (in the range 1 to 31).

### wxDate::GetDayOfWeek

int GetDayOfWeek() const

Returns the integer day of the week (in the range 1 to 7).

### wxDate::GetDayOfWeekName

wxString GetDayOfWeekName() const

Returns the name of the day of week.

### wxDate::GetDayOfYear

long GetDayOfYear() const

Returns the day of the year (from 1 to 365).

### wxDate::GetDaysInMonth

int GetDaysInMonth() const

Returns the number of days in the month (in the range 1 to 31).

### wxDate::GetFirstDayOfMonth

int GetFirstDayOfMonth() const

Returns the day of week that is first in the month (in the range 1 to 7).

### wxDate::GetJulianDate

long GetJulianDate() const

Returns the Julian date.

### wxDate::GetMonth

int GetMonth() const

Returns the month number (in the range 1 to 12).

### wxDate::GetMonthEnd

wxDate GetMonthEnd()

Returns the date representing the last day of the month.

### wxDate::GetMonthName

wxString GetMonthName() const

Returns the name of the month. Do not delete the returned storage.

### wxDate::GetMonthStart

wxDate GetMonthStart() const

Returns the date representing the first day of the month.

### wxDate::GetWeekOfMonth

int GetWeekOfMonth() const

Returns the week of month (in the range 1 to 6).

### wxDate::GetWeekOfYear

int GetWeekOfYear() const

Returns the week of year (in the range 1 to 52).

### wxDate::GetYear

int GetYear() const

Returns the year as an integer (such as '1995').

### wxDate::GetYearEnd

wxDate GetYearEnd() const

Returns the date representing the last day of the year.

### wxDate::GetYearStart

wxDate GetYearStart() const

Returns the date representing the first day of the year.

### wxDate::IsLeapYear

bool IsLeapYear() const

Returns TRUE if the year of this date is a leap year.

### wxDate::Set

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.

### wxDate::SetFormat

void SetFormat(int format)

Sets the current format type.

Parameters

format

-1 or one of:

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.

### wxDate::SetOption

int SetOption(int option, const bool enable=TRUE)

Enables or disables an option for formatting.

Parameters

option

May be one of:

wxNO_CENTURY | The century is not formatted.
wxDATE_ABBR | Month and day names are abbreviated to 3 characters when formatting.

### wxDate::operator wxString

operator wxString()

Conversion operator, to convert wxDate to wxString by calling FormatDate.

### wxDate::operator +

wxDate operator +(long i)

wxDate operator +(int i)

Adds an integer number of days to the date, returning a date.

### wxDate::operator -

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 +=

wxDate& operator +=(long i)

Postfix operator: adds an integer number of days to the date, returning a reference to 'this' date.

### wxDate::operator -=

wxDate& operator -=(long i)

Postfix operator: subtracts an integer number of days from the date, returning a reference to 'this' date.

### wxDate::operator ++

wxDate& operator ++()

Increments the date (postfix or prefix).

### wxDate::operator --

wxDate& operator --()

Decrements the date (postfix or prefix).

### wxDate::operator <

friend bool operator <(const wxDate& date1, const wxDate& date2)

Function to compare two dates, returning TRUE if date1 is earlier than date2.

### wxDate::operator <=

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.

### wxDate::operator >

friend bool operator >(const wxDate& date1, const wxDate& date2)

Function to compare two dates, returning TRUE if date1 is later than date2.

### wxDate::operator >=

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.

### wxDate::operator ==

friend bool operator ==(const wxDate& date1, const wxDate& date2)

Function to compare two dates, returning TRUE if date1 is equal to date2.

### wxDate::operator !=

friend bool operator !=(const wxDate& date1, const wxDate& date2)

Function to compare two dates, returning TRUE if date1 is not equal to date2.

### wxDate::operator <<

friend ostream& operator <<(ostream& os, const wxDate& date)

Function to output a wxDate to an ostream.