]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/datetime.h
wxLaunchDefaultBrowser() now supports wxBROWSER_NEW_WINDOW flag (and it actually...
[wxWidgets.git] / include / wx / datetime.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/datetime.h
3// Purpose: declarations of time/date related classes (wxDateTime,
4// wxTimeSpan)
5// Author: Vadim Zeitlin
6// Modified by:
7// Created: 10.02.99
8// RCS-ID: $Id$
9// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef _WX_DATETIME_H
14#define _WX_DATETIME_H
15
16#include "wx/defs.h"
17
18#if wxUSE_DATETIME
19
20#ifndef __WXWINCE__
21#include <time.h>
22#else
23#include "wx/msw/wince/time.h"
24#endif
25
26#include <limits.h> // for INT_MIN
27
28#include "wx/longlong.h"
29
30class WXDLLIMPEXP_BASE wxDateTime;
31class WXDLLIMPEXP_BASE wxTimeSpan;
32class WXDLLIMPEXP_BASE wxDateSpan;
33
34#include "wx/dynarray.h"
35
36// not all c-runtimes are based on 1/1/1970 being (time_t) 0
37// set this to the corresponding value in seconds 1/1/1970 has on your
38// systems c-runtime
39
40#if defined(__WXMAC__) && !defined(__DARWIN__) && __MSL__ < 0x6000
41 #define WX_TIME_BASE_OFFSET ( 2082844800L + 126144000L )
42#else
43 #define WX_TIME_BASE_OFFSET 0
44#endif
45/*
46 * TODO
47 *
48 * + 1. Time zones with minutes (make TimeZone a class)
49 * ? 2. getdate() function like under Solaris
50 * + 3. text conversion for wxDateSpan
51 * + 4. pluggable modules for the workdays calculations
52 * 5. wxDateTimeHolidayAuthority for Easter and other christian feasts
53 */
54
55/*
56 The three (main) classes declared in this header represent:
57
58 1. An absolute moment in the time (wxDateTime)
59 2. A difference between two moments in the time, positive or negative
60 (wxTimeSpan)
61 3. A logical difference between two dates expressed in
62 years/months/weeks/days (wxDateSpan)
63
64 The following arithmetic operations are permitted (all others are not):
65
66 addition
67 --------
68
69 wxDateTime + wxTimeSpan = wxDateTime
70 wxDateTime + wxDateSpan = wxDateTime
71 wxTimeSpan + wxTimeSpan = wxTimeSpan
72 wxDateSpan + wxDateSpan = wxDateSpan
73
74 subtraction
75 ------------
76 wxDateTime - wxDateTime = wxTimeSpan
77 wxDateTime - wxTimeSpan = wxDateTime
78 wxDateTime - wxDateSpan = wxDateTime
79 wxTimeSpan - wxTimeSpan = wxTimeSpan
80 wxDateSpan - wxDateSpan = wxDateSpan
81
82 multiplication
83 --------------
84 wxTimeSpan * number = wxTimeSpan
85 number * wxTimeSpan = wxTimeSpan
86 wxDateSpan * number = wxDateSpan
87 number * wxDateSpan = wxDateSpan
88
89 unitary minus
90 -------------
91 -wxTimeSpan = wxTimeSpan
92 -wxDateSpan = wxDateSpan
93
94 For each binary operation OP (+, -, *) we have the following operatorOP=() as
95 a method and the method with a symbolic name OPER (Add, Subtract, Multiply)
96 as a synonym for it and another const method with the same name which returns
97 the changed copy of the object and operatorOP() as a global function which is
98 implemented in terms of the const version of OPEN. For the unary - we have
99 operator-() as a method, Neg() as synonym for it and Negate() which returns
100 the copy of the object with the changed sign.
101*/
102
103// an invalid/default date time object which may be used as the default
104// argument for arguments of type wxDateTime; it is also returned by all
105// functions returning wxDateTime on failure (this is why it is also called
106// wxInvalidDateTime)
107class WXDLLIMPEXP_BASE wxDateTime;
108
109extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultDateTimeFormat;
110extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultTimeSpanFormat;
111extern WXDLLIMPEXP_DATA_BASE(const wxDateTime) wxDefaultDateTime;
112
113#define wxInvalidDateTime wxDefaultDateTime
114
115// ----------------------------------------------------------------------------
116// wxDateTime represents an absolute moment in the time
117// ----------------------------------------------------------------------------
118
119class WXDLLIMPEXP_BASE wxDateTime
120{
121public:
122 // types
123 // ------------------------------------------------------------------------
124
125 // a small unsigned integer type for storing things like minutes,
126 // seconds &c. It should be at least short (i.e. not char) to contain
127 // the number of milliseconds - it may also be 'int' because there is
128 // no size penalty associated with it in our code, we don't store any
129 // data in this format
130 typedef unsigned short wxDateTime_t;
131
132 // constants
133 // ------------------------------------------------------------------------
134
135 // the timezones
136 enum TZ
137 {
138 // the time in the current time zone
139 Local,
140
141 // zones from GMT (= Greenwhich Mean Time): they're guaranteed to be
142 // consequent numbers, so writing something like `GMT0 + offset' is
143 // safe if abs(offset) <= 12
144
145 // underscore stands for minus
146 GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7,
147 GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
148 GMT0,
149 GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
150 GMT7, GMT8, GMT9, GMT10, GMT11, GMT12,
151 // Note that GMT12 and GMT_12 are not the same: there is a difference
152 // of exactly one day between them
153
154 // some symbolic names for TZ
155
156 // Europe
157 WET = GMT0, // Western Europe Time
158 WEST = GMT1, // Western Europe Summer Time
159 CET = GMT1, // Central Europe Time
160 CEST = GMT2, // Central Europe Summer Time
161 EET = GMT2, // Eastern Europe Time
162 EEST = GMT3, // Eastern Europe Summer Time
163 MSK = GMT3, // Moscow Time
164 MSD = GMT4, // Moscow Summer Time
165
166 // US and Canada
167 AST = GMT_4, // Atlantic Standard Time
168 ADT = GMT_3, // Atlantic Daylight Time
169 EST = GMT_5, // Eastern Standard Time
170 EDT = GMT_4, // Eastern Daylight Saving Time
171 CST = GMT_6, // Central Standard Time
172 CDT = GMT_5, // Central Daylight Saving Time
173 MST = GMT_7, // Mountain Standard Time
174 MDT = GMT_6, // Mountain Daylight Saving Time
175 PST = GMT_8, // Pacific Standard Time
176 PDT = GMT_7, // Pacific Daylight Saving Time
177 HST = GMT_10, // Hawaiian Standard Time
178 AKST = GMT_9, // Alaska Standard Time
179 AKDT = GMT_8, // Alaska Daylight Saving Time
180
181 // Australia
182
183 A_WST = GMT8, // Western Standard Time
184 A_CST = GMT12 + 1, // Central Standard Time (+9.5)
185 A_EST = GMT10, // Eastern Standard Time
186 A_ESST = GMT11, // Eastern Summer Time
187
188 // TODO add more symbolic timezone names here
189
190 // Universal Coordinated Time = the new and politically correct name
191 // for GMT
192 UTC = GMT0
193 };
194
195 // the calendar systems we know about: notice that it's valid (for
196 // this classes purpose anyhow) to work with any of these calendars
197 // even with the dates before the historical appearance of the
198 // calendar
199 enum Calendar
200 {
201 Gregorian, // current calendar
202 Julian // calendar in use since -45 until the 1582 (or later)
203
204 // TODO Hebrew, Chinese, Maya, ... (just kidding) (or then may be not?)
205 };
206
207 // these values only are used to identify the different dates of
208 // adoption of the Gregorian calendar (see IsGregorian())
209 //
210 // All data and comments taken verbatim from "The Calendar FAQ (v 2.0)"
211