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