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