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