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