]>
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
);
55 operator wxString (void);
56 void operator = (const wxDate
& date
);
57 void operator = (const wxString
& date
);
59 wxDate
operator + (long i
);
60 wxDate
operator + (int i
);
62 wxDate
operator - (long i
);
63 wxDate
operator - (int i
);
65 long operator - (const wxDate
&dt
);
67 wxDate
&operator += (long i
);
68 wxDate
&operator -= (long i
);
70 wxDate
&operator ++ (); // Prefix increment
71 wxDate
&operator ++ (int); // Postfix increment
72 wxDate
&operator -- (); // Prefix decrement
73 wxDate
&operator -- (int); // Postfix decrement
75 friend bool WXDLLEXPORT
operator < (const wxDate
&dt1
, const wxDate
&dt2
);
76 friend bool WXDLLEXPORT
operator <= (const wxDate
&dt1
, const wxDate
&dt2
);
77 friend bool WXDLLEXPORT
operator > (const wxDate
&dt1
, const wxDate
&dt2
);
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
);
82 friend ostream
& WXDLLEXPORT
operator << (ostream
&os
, const wxDate
&dt
);
84 wxString
FormatDate (int type
=-1) const;
85 void SetFormat (int format
);
86 int SetOption (int option
, bool enable
=TRUE
);
88 long GetJulianDate() const; // returns julian date
89 int GetDayOfYear() const; // returns relative date since Jan. 1
90 bool IsLeapYear() const; // returns TRUE if leap year, FALSE if not
92 // Version 4.0 Extension to Public Interface - CDP
94 // These 'Set's modify the date object and actually SET it
95 // They all return a reference to self (*this)
97 wxDate
&Set(); // Sets to current system date
98 wxDate
&Set(long lJulian
);
99 wxDate
&Set(int nMonth
, int nDay
, int nYear
);
101 wxDate
&AddWeeks(int nCount
= 1); //
102 wxDate
&AddMonths(int nCount
= 1); // May also pass neg# to decrement
103 wxDate
&AddYears(int nCount
= 1); //
105 int GetDay() const; // Numeric Day of date object
106 int GetDaysInMonth(); // Number of days in month (1..31)
107 int GetFirstDayOfMonth() const; // First Day Of Month (1..7)
109 wxString
GetDayOfWeekName(); // Character Day Of Week ('Sunday'..'Saturday')
110 int GetDayOfWeek() const; // (1..7)
112 int GetWeekOfMonth(); // Numeric Week Of Month (1..6)
113 int GetWeekOfYear(); // Numeric Week Of Year (1..52)
115 wxString
GetMonthName(); // Character Month name
116 int GetMonth() const; // Month Number (1..12)
117 wxDate
GetMonthStart(); // First Date Of Month
118 wxDate
GetMonthEnd(); // Last Date Of Month
120 int GetYear() const; // eg. 1992
121 wxDate
GetYearStart(); // First Date Of Year
122 wxDate
GetYearEnd(); // Last Date Of Year
124 bool IsBetween(const wxDate
& first
, const wxDate
& second
) const;
126 wxDate
Previous(int dayOfWeek
) const;