]> git.saurik.com Git - wxWidgets.git/blame - include/wx/date.h
no message
[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
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
ac57418f 23#ifdef wxUSE_TIMEDATE
c801d85f
KB
24
25enum wxdate_format_type {wxMDY, wxDAY, wxMONTH, wxFULL, wxEUROPEAN};
26
27#define wxNO_CENTURY 0x02
28#define wxDATE_ABBR 0x04
29
30class 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
55 operator wxString (void);
56 void operator = (const wxDate& date);
57 void operator = (const wxString& date);
58
debe6624
JS
59 wxDate operator + (long i);
60 wxDate operator + (int i);
c801d85f 61
debe6624
JS
62 wxDate operator - (long i);
63 wxDate operator - (int i);
c801d85f
KB
64
65 long operator - (const wxDate &dt);
66
debe6624
JS
67 wxDate &operator += (long i);
68 wxDate &operator -= (long i);
c801d85f
KB
69
70 wxDate &operator ++ (); // Prefix increment
71 wxDate &operator ++ (int); // Postfix increment
72 wxDate &operator -- (); // Prefix decrement
73 wxDate &operator -- (int); // Postfix decrement
74
75 friend bool operator < (const wxDate &dt1, const wxDate &dt2);
76 friend bool operator <= (const wxDate &dt1, const wxDate &dt2);
77 friend bool operator > (const wxDate &dt1, const wxDate &dt2);
78 friend bool operator >= (const wxDate &dt1, const wxDate &dt2);
79 friend bool operator == (const wxDate &dt1, const wxDate &dt2);
80 friend bool operator != (const wxDate &dt1, const wxDate &dt2);
81
82 friend ostream &operator << (ostream &os, const wxDate &dt);
83
debe6624
JS
84 wxString FormatDate (int type=-1) const;
85 void SetFormat (int format);
86 int SetOption (int option, bool enable=TRUE);
c801d85f
KB
87
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
91
92 // Version 4.0 Extension to Public Interface - CDP
93
94 // These 'Set's modify the date object and actually SET it
95 // They all return a reference to self (*this)
96
97 wxDate &Set(); // Sets to current system date
98 wxDate &Set(long lJulian);
99 wxDate &Set(int nMonth, int nDay, int nYear);
100
101 wxDate &AddWeeks(int nCount = 1); //
102 wxDate &AddMonths(int nCount = 1); // May also pass neg# to decrement
103 wxDate &AddYears(int nCount = 1); //
104
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)
108
109 wxString GetDayOfWeekName(); // Character Day Of Week ('Sunday'..'Saturday')
110 int GetDayOfWeek() const; // (1..7)
111
112 int GetWeekOfMonth(); // Numeric Week Of Month (1..6)
113 int GetWeekOfYear(); // Numeric Week Of Year (1..52)
114
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
119
120 int GetYear() const; // eg. 1992
121 wxDate GetYearStart(); // First Date Of Year
122 wxDate GetYearEnd(); // Last Date Of Year
123
124 bool IsBetween(const wxDate& first, const wxDate& second) const;
125
debe6624 126 wxDate Previous(int dayOfWeek) const;
c801d85f
KB
127};
128
129#endif
130#endif
34138703 131 // _WX_DATE_H_