]>
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"
24 // These lines necessary to stop VC++ 6 being confused about namespaces
25 class WXDLLEXPORT wxDate
;
26 bool WXDLLEXPORT
operator<(const wxDate
&dt1
, const wxDate
&dt2
);
27 bool WXDLLEXPORT
operator<(const wxDate
&dt1
, const wxDate
&dt2
);
28 bool WXDLLEXPORT
operator <= (const wxDate
&dt1
, const wxDate
&dt2
);
29 bool WXDLLEXPORT
operator > (const wxDate
&dt1
, const wxDate
&dt2
);
30 bool WXDLLEXPORT
operator >= (const wxDate
&dt1
, const wxDate
&dt2
);
31 bool WXDLLEXPORT
operator == (const wxDate
&dt1
, const wxDate
&dt2
);
32 bool WXDLLEXPORT
operator != (const wxDate
&dt1
, const wxDate
&dt2
);
34 enum wxdate_format_type
{wxMDY
, wxDAY
, wxMONTH
, wxFULL
, wxEUROPEAN
};
36 #define wxNO_CENTURY 0x02
37 #define wxDATE_ABBR 0x04
39 class WXDLLEXPORT wxDate
: public wxObject
41 DECLARE_DYNAMIC_CLASS(wxDate
)
44 unsigned long julian
; // see julDate(); days since 1/1/4713 B.C.
45 int month
; // see NMonth()
47 int year
; // see NYear4()
48 int day_of_week
; // see NDOW(); 1 = Sunday, ... 7 = Saturday
52 unsigned char DisplayOptions
;
54 void julian_to_mdy (); // convert julian day to mdy
55 void julian_to_wday (); // convert julian day to day_of_week
56 void mdy_to_julian (); // convert mdy to julian day
61 wxDate (int m
, int d
, int y
);
62 wxDate (const wxString
& dat
);
63 wxDate (const wxDate
&dt
);
66 operator wxString (void);
69 void operator = (const wxDate
& date
);
70 void operator = (const wxString
& date
);
72 wxDate
operator + (long i
);
73 wxDate
operator + (int i
);
75 wxDate
operator - (long i
);
76 wxDate
operator - (int i
);
78 long operator - (const wxDate
&dt
);
80 wxDate
&operator += (long i
);
81 wxDate
&operator -= (long i
);
83 wxDate
&operator ++ (); // Prefix increment
84 wxDate
&operator ++ (int); // Postfix increment
85 wxDate
&operator -- (); // Prefix decrement
86 wxDate
&operator -- (int); // Postfix decrement
88 friend bool WXDLLEXPORT
operator < (const wxDate
&dt1
, const wxDate
&dt2
);
89 friend bool WXDLLEXPORT
operator <= (const wxDate
&dt1
, const wxDate
&dt2
);
90 friend bool WXDLLEXPORT
operator > (const wxDate
&dt1
, const wxDate
&dt2
);
91 friend bool WXDLLEXPORT
operator >= (const wxDate
&dt1
, const wxDate
&dt2
);
92 friend bool WXDLLEXPORT
operator == (const wxDate
&dt1
, const wxDate
&dt2
);
93 friend bool WXDLLEXPORT
operator != (const wxDate
&dt1
, const wxDate
&dt2
);
95 friend ostream WXDLLEXPORT
& operator << (ostream
&os
, const wxDate
&dt
);
97 wxString
FormatDate (int type
=-1) const;
98 void SetFormat (int format
);
99 int SetOption (int option
, bool enable
=TRUE
);
101 long GetJulianDate() const; // returns julian date
102 int GetDayOfYear() const; // returns relative date since Jan. 1
103 bool IsLeapYear() const; // returns TRUE if leap year, FALSE if not
105 // Version 4.0 Extension to Public Interface - CDP
107 // These 'Set's modify the date object and actually SET it
108 // They all return a reference to self (*this)
110 wxDate
&Set(); // Sets to current system date
111 wxDate
&Set(long lJulian
);
112 wxDate
&Set(int nMonth
, int nDay
, int nYear
);
114 wxDate
&AddWeeks(int nCount
= 1); //
115 wxDate
&AddMonths(int nCount
= 1); // May also pass neg# to decrement
116 wxDate
&AddYears(int nCount
= 1); //
118 int GetDay() const; // Numeric Day of date object
119 int GetDaysInMonth(); // Number of days in month (1..31)
120 int GetFirstDayOfMonth() const; // First Day Of Month (1..7)
122 wxString
GetDayOfWeekName(); // Character Day Of Week ('Sunday'..'Saturday')
123 int GetDayOfWeek() const; // (1..7)
125 int GetWeekOfMonth(); // Numeric Week Of Month (1..6)
126 int GetWeekOfYear(); // Numeric Week Of Year (1..52)
128 wxString
GetMonthName(); // Character Month name
129 int GetMonth() const; // Month Number (1..12)
130 wxDate
GetMonthStart(); // First Date Of Month
131 wxDate
GetMonthEnd(); // Last Date Of Month
133 int GetYear() const; // eg. 1992
134 wxDate
GetYearStart(); // First Date Of Year
135 wxDate
GetYearEnd(); // Last Date Of Year
137 bool IsBetween(const wxDate
& first
, const wxDate
& second
) const;
139 wxDate
Previous(int dayOfWeek
) const;
142 #endif // wxUSE_TIMEDATE