]> git.saurik.com Git - wxWidgets.git/blob - include/wx/date.h
fixes for compilation without wxUSE_TOOLTIPS
[wxWidgets.git] / include / wx / date.h
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
13 #ifndef _WX_DATE_H_
14 #define _WX_DATE_H_
15
16 #ifdef __GNUG__
17 #pragma interface "date.h"
18 #endif
19
20 #include "wx/object.h"
21 #include "wx/string.h"
22
23 #if wxUSE_TIMEDATE
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 ();
50 wxDate (long j);
51 wxDate (int m, int d, int y);
52 wxDate (const wxString& dat);
53 wxDate (const wxDate &dt);
54
55 #ifndef __SALFORDC__
56 operator wxString (void);
57 #endif
58
59 void operator = (const wxDate& date);
60 void operator = (const wxString& date);
61
62 wxDate operator + (long i);
63 wxDate operator + (int i);
64
65 wxDate operator - (long i);
66 wxDate operator - (int i);
67
68 long operator - (const wxDate &dt);
69
70 wxDate &operator += (long i);
71 wxDate &operator -= (long i);
72
73 wxDate &operator ++ (); // Prefix increment
74 wxDate &operator ++ (int); // Postfix increment
75 wxDate &operator -- (); // Prefix decrement
76 wxDate &operator -- (int); // Postfix decrement
77
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);
86
87 wxString FormatDate (int type=-1) const;
88 void SetFormat (int format);
89 int SetOption (int option, bool enable=TRUE);
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
129 wxDate Previous(int dayOfWeek) const;
130 };
131
132 #endif
133 #endif
134 // _WX_DATE_H_