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