]> git.saurik.com Git - wxWidgets.git/blame - include/wx/date.h
SetIcon added
[wxWidgets.git] / include / wx / date.h
CommitLineData
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
c30aaf75 6// Modified by:
c801d85f
KB
7// Created: 01/02/97
8// RCS-ID: $Id$
9// Copyright: (c)
c30aaf75 10// Licence: wxWindows licence
c801d85f
KB
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
dbda9e86
JS
24// These lines necessary to stop VC++ 6 being confused about namespaces
25class WXDLLEXPORT wxDate;
26bool WXDLLEXPORT operator<(const wxDate &dt1, const wxDate &dt2);
27bool WXDLLEXPORT operator<(const wxDate &dt1, const wxDate &dt2);
28bool WXDLLEXPORT operator <= (const wxDate &dt1, const wxDate &dt2);
29bool WXDLLEXPORT operator > (const wxDate &dt1, const wxDate &dt2);
30bool WXDLLEXPORT operator >= (const wxDate &dt1, const wxDate &dt2);
31bool WXDLLEXPORT operator == (const wxDate &dt1, const wxDate &dt2);
32bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2);
c801d85f
KB
33
34enum wxdate_format_type {wxMDY, wxDAY, wxMONTH, wxFULL, wxEUROPEAN};
35
36#define wxNO_CENTURY 0x02
37#define wxDATE_ABBR 0x04
38
c30aaf75 39class WXDLLEXPORT wxDate : public wxObject
c801d85f 40{
c30aaf75
VZ
41DECLARE_DYNAMIC_CLASS(wxDate)
42
43protected:
44 unsigned long julian; // see julDate(); days since 1/1/4713 B.C.
45 int month; // see NMonth()
46 int day; // see Day()
47 int year; // see NYear4()
48 int day_of_week; // see NDOW(); 1 = Sunday, ... 7 = Saturday
49
50private:
51 int DisplayFormat;
52 unsigned char DisplayOptions;
53
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
57
58public:
59 wxDate ();
60 wxDate (long j);
61 wxDate (int m, int d, int y);
62 wxDate (const wxString& dat);
63 wxDate (const wxDate &dt);
c801d85f 64
ce3ed50d 65#ifndef __SALFORDC__
c30aaf75 66 operator wxString (void);
ce3ed50d
JS
67#endif
68
c30aaf75
VZ
69 void operator = (const wxDate& date);
70 void operator = (const wxString& date);
c801d85f 71
c30aaf75
VZ
72 wxDate operator + (long i);
73 wxDate operator + (int i);
c801d85f 74
c30aaf75
VZ
75 wxDate operator - (long i);
76 wxDate operator - (int i);
c801d85f 77
c30aaf75 78 long operator - (const wxDate &dt);
c801d85f 79
c30aaf75
VZ
80 wxDate &operator += (long i);
81 wxDate &operator -= (long i);
c801d85f 82
c30aaf75
VZ
83 wxDate &operator ++ (); // Prefix increment
84 wxDate &operator ++ (int); // Postfix increment
85 wxDate &operator -- (); // Prefix decrement
86 wxDate &operator -- (int); // Postfix decrement
c801d85f 87
c30aaf75
VZ
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);
d851f77e 94
38830220 95#if wxUSE_STD_IOSTREAM
c30aaf75 96 friend ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt);
38830220 97#endif
c801d85f 98
c30aaf75
VZ
99 wxString FormatDate (int type=-1) const;
100 void SetFormat (int format);
101 int SetOption (int option, bool enable=TRUE);
c801d85f 102
c30aaf75
VZ
103 long GetJulianDate() const; // returns julian date
104 int GetDayOfYear() const; // returns relative date since Jan. 1
105 bool IsLeapYear() const; // returns TRUE if leap year, FALSE if not
c801d85f 106
c30aaf75 107 // Version 4.0 Extension to Public Interface - CDP
c801d85f 108
c30aaf75
VZ
109 // These 'Set's modify the date object and actually SET it
110 // They all return a reference to self (*this)
c801d85f 111
c30aaf75
VZ
112 wxDate &Set(); // Sets to current system date
113 wxDate &Set(long lJulian);
114 wxDate &Set(int nMonth, int nDay, int nYear);
c801d85f 115
c30aaf75
VZ
116 wxDate &AddWeeks(int nCount = 1); //
117 wxDate &AddMonths(int nCount = 1); // May also pass neg# to decrement
118 wxDate &AddYears(int nCount = 1); //
c801d85f 119
c30aaf75
VZ
120 int GetDay() const; // Numeric Day of date object
121 int GetDaysInMonth(); // Number of days in month (1..31)
122 int GetFirstDayOfMonth() const; // First Day Of Month (1..7)
c801d85f 123
c30aaf75
VZ
124 wxString GetDayOfWeekName(); // Character Day Of Week ('Sunday'..'Saturday')
125 int GetDayOfWeek() const; // (1..7)
c801d85f 126
c30aaf75
VZ
127 int GetWeekOfMonth(); // Numeric Week Of Month (1..6)
128 int GetWeekOfYear(); // Numeric Week Of Year (1..52)
c801d85f 129
c30aaf75
VZ
130 wxString GetMonthName(); // Character Month name
131 int GetMonth() const; // Month Number (1..12)
132 wxDate GetMonthStart(); // First Date Of Month
133 wxDate GetMonthEnd(); // Last Date Of Month
c801d85f 134
c30aaf75
VZ
135 int GetYear() const; // eg. 1992
136 wxDate GetYearStart(); // First Date Of Year
137 wxDate GetYearEnd(); // Last Date Of Year
c801d85f 138
c30aaf75
VZ
139 bool IsBetween(const wxDate& first, const wxDate& second) const;
140
141 wxDate Previous(int dayOfWeek) const;
c801d85f
KB
142};
143
c30aaf75 144#endif // wxUSE_TIMEDATE
c801d85f 145#endif
34138703 146 // _WX_DATE_H_