]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/date.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDate class
4 // Author: Julian Smart, Steve Marcus, Eric Simon, Chris Hill,
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
17 #pragma interface "date.h"
20 #include "wx/object.h"
21 #include "wx/string.h"
25 enum wxdate_format_type
{wxMDY
, wxDAY
, wxMONTH
, wxFULL
, wxEUROPEAN
};
27 #define wxNO_CENTURY 0x02
28 #define wxDATE_ABBR 0x04
30 class WXDLLEXPORT wxDate
: public wxObject
32 DECLARE_DYNAMIC_CLASS(wxDate
)
34 unsigned long julian
; // see julDate(); days since 1/1/4713 B.C.
35 int month
; // see NMonth()
37 int year
; // see NYear4()
38 int day_of_week
; // see NDOW(); 1 = Sunday, ... 7 = Saturday
42 unsigned char DisplayOptions
;
44 void julian_to_mdy (); // convert julian day to mdy
45 void julian_to_wday (); // convert julian day to day_of_week
46 void mdy_to_julian (); // convert mdy to julian day
51 wxDate (int m
, int d
, int y
);
52 wxDate (const wxString
& dat
);
53 wxDate (const wxDate
&dt
);
56 operator wxString (void);
59 void operator = (const wxDate
& date
);
60 void operator = (const wxString
& date
);
62 wxDate
operator + (long i
);
63 wxDate
operator + (int i
);
65 wxDate
operator - (long i
);
66 wxDate
operator - (int i
);
68 long operator - (const wxDate
&dt
);
70 wxDate
&operator += (long i
);
71 wxDate
&operator -= (long i
);
73 wxDate
&operator ++ (); // Prefix increment
74 wxDate
&operator ++ (int); // Postfix increment
75 wxDate
&operator -- (); // Prefix decrement
76 wxDate
&operator -- (int); // Postfix decrement
78 friend bool WXDLLEXPORT
operator < (const wxDate
&dt1
, const wxDate
&dt2
);
79 friend bool WXDLLEXPORT
operator <= (const wxDate
&dt1
, const wxDate
&dt2
);
80 friend bool WXDLLEXPORT
operator > (const wxDate
&dt1
, const wxDate
&dt2
);
81 friend bool WXDLLEXPORT
operator >= (const wxDate
&dt1
, const wxDate
&dt2
);
82 friend bool WXDLLEXPORT
operator == (const wxDate
&dt1
, const wxDate
&dt2
);
83 friend bool WXDLLEXPORT
operator != (const wxDate
&dt1
, const wxDate
&dt2
);
85 friend ostream
& WXDLLEXPORT
operator << (ostream
&os
, const wxDate
&dt
);
87 wxString
FormatDate (int type
=-1) const;
88 void SetFormat (int format
);
89 int SetOption (int option
, bool enable
=TRUE
);
91 long GetJulianDate() const; // returns julian date
92 int GetDayOfYear() const; // returns relative date since Jan. 1
93 bool IsLeapYear() const; // returns TRUE if leap year, FALSE if not
95 // Version 4.0 Extension to Public Interface - CDP
97 // These 'Set's modify the date object and actually SET it
98 // They all return a reference to self (*this)
100 wxDate
&Set(); // Sets to current system date
101 wxDate
&Set(long lJulian
);
102 wxDate
&Set(int nMonth
, int nDay
, int nYear
);
104 wxDate
&AddWeeks(int nCount
= 1); //
105 wxDate
&AddMonths(int nCount
= 1); // May also pass neg# to decrement
106 wxDate
&AddYears(int nCount
= 1); //
108 int GetDay() const; // Numeric Day of date object
109 int GetDaysInMonth(); // Number of days in month (1..31)
110 int GetFirstDayOfMonth() const; // First Day Of Month (1..7)
112 wxString
GetDayOfWeekName(); // Character Day Of Week ('Sunday'..'Saturday')
113 int GetDayOfWeek() const; // (1..7)
115 int GetWeekOfMonth(); // Numeric Week Of Month (1..6)
116 int GetWeekOfYear(); // Numeric Week Of Year (1..52)
118 wxString
GetMonthName(); // Character Month name
119 int GetMonth() const; // Month Number (1..12)
120 wxDate
GetMonthStart(); // First Date Of Month
121 wxDate
GetMonthEnd(); // Last Date Of Month
123 int GetYear() const; // eg. 1992
124 wxDate
GetYearStart(); // First Date Of Year
125 wxDate
GetYearEnd(); // Last Date Of Year
127 bool IsBetween(const wxDate
& first
, const wxDate
& second
) const;
129 wxDate
Previous(int dayOfWeek
) const;