]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: date.h | |
3 | // Purpose: wxDate class | |
4 | // Author: Julian Smart, Steve Marcus, Eric Simon, Chris Hill, | |
5 | // Charles D. Price | |
6 | // Modified by: | |
7 | // Created: 01/02/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) | |
10 | // Licence: wxWindows licence | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
34138703 JS |
13 | #ifndef _WX_DATE_H_ |
14 | #define _WX_DATE_H_ | |
c801d85f KB |
15 | |
16 | #ifdef __GNUG__ | |
17 | #pragma interface "date.h" | |
18 | #endif | |
19 | ||
20 | #include "wx/object.h" | |
21 | #include "wx/string.h" | |
22 | ||
9838df2c | 23 | #if wxUSE_TIMEDATE |
c801d85f KB |
24 | |
25 | enum wxdate_format_type {wxMDY, wxDAY, wxMONTH, wxFULL, wxEUROPEAN}; | |
26 | ||
27 | #define wxNO_CENTURY 0x02 | |
28 | #define wxDATE_ABBR 0x04 | |
29 | ||
30 | class WXDLLEXPORT wxDate: public wxObject | |
31 | { | |
32 | DECLARE_DYNAMIC_CLASS(wxDate) | |
33 | protected: | |
34 | unsigned long julian; // see julDate(); days since 1/1/4713 B.C. | |
35 | int month; // see NMonth() | |
36 | int day; // see Day() | |
37 | int year; // see NYear4() | |
38 | int day_of_week; // see NDOW(); 1 = Sunday, ... 7 = Saturday | |
39 | ||
40 | private: | |
41 | int DisplayFormat; | |
42 | unsigned char DisplayOptions; | |
43 | ||
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 | |
47 | ||
48 | public: | |
49 | wxDate (); | |
debe6624 JS |
50 | wxDate (long j); |
51 | wxDate (int m, int d, int y); | |
c801d85f KB |
52 | wxDate (const wxString& dat); |
53 | wxDate (const wxDate &dt); | |
54 | ||
ce3ed50d | 55 | #ifndef __SALFORDC__ |
c801d85f | 56 | operator wxString (void); |
ce3ed50d JS |
57 | #endif |
58 | ||
c801d85f KB |
59 | void operator = (const wxDate& date); |
60 | void operator = (const wxString& date); | |
61 | ||
debe6624 JS |
62 | wxDate operator + (long i); |
63 | wxDate operator + (int i); | |
c801d85f | 64 | |
debe6624 JS |
65 | wxDate operator - (long i); |
66 | wxDate operator - (int i); | |
c801d85f KB |
67 | |
68 | long operator - (const wxDate &dt); | |
69 | ||
debe6624 JS |
70 | wxDate &operator += (long i); |
71 | wxDate &operator -= (long i); | |
c801d85f KB |
72 | |
73 | wxDate &operator ++ (); // Prefix increment | |
74 | wxDate &operator ++ (int); // Postfix increment | |
75 | wxDate &operator -- (); // Prefix decrement | |
76 | wxDate &operator -- (int); // Postfix decrement | |
77 | ||
d851f77e UU |
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); | |
84 | ||
85 | friend ostream& WXDLLEXPORT operator << (ostream &os, const wxDate &dt); | |
c801d85f | 86 | |
debe6624 JS |
87 | wxString FormatDate (int type=-1) const; |
88 | void SetFormat (int format); | |
89 | int SetOption (int option, bool enable=TRUE); | |
c801d85f KB |
90 | |
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 | |
94 | ||
95 | // Version 4.0 Extension to Public Interface - CDP | |
96 | ||
97 | // These 'Set's modify the date object and actually SET it | |
98 | // They all return a reference to self (*this) | |
99 | ||
100 | wxDate &Set(); // Sets to current system date | |
101 | wxDate &Set(long lJulian); | |
102 | wxDate &Set(int nMonth, int nDay, int nYear); | |
103 | ||
104 | wxDate &AddWeeks(int nCount = 1); // | |
105 | wxDate &AddMonths(int nCount = 1); // May also pass neg# to decrement | |
106 | wxDate &AddYears(int nCount = 1); // | |
107 | ||
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) | |
111 | ||
112 | wxString GetDayOfWeekName(); // Character Day Of Week ('Sunday'..'Saturday') | |
113 | int GetDayOfWeek() const; // (1..7) | |
114 | ||
115 | int GetWeekOfMonth(); // Numeric Week Of Month (1..6) | |
116 | int GetWeekOfYear(); // Numeric Week Of Year (1..52) | |
117 | ||
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 | |
122 | ||
123 | int GetYear() const; // eg. 1992 | |
124 | wxDate GetYearStart(); // First Date Of Year | |
125 | wxDate GetYearEnd(); // Last Date Of Year | |
126 | ||
127 | bool IsBetween(const wxDate& first, const wxDate& second) const; | |
128 | ||
debe6624 | 129 | wxDate Previous(int dayOfWeek) const; |
c801d85f KB |
130 | }; |
131 | ||
132 | #endif | |
133 | #endif | |
34138703 | 134 | // _WX_DATE_H_ |