]> git.saurik.com Git - wxWidgets.git/blame - include/wx/datetime.h
rtf cut&paste works now, html export fixed
[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 *
40 * 1. Time zones with minutes (make wxTimeZone a class)
41 * 2. getdate() function like under Solaris
42 * 3. text conversion for wxDateSpan
43 */
44
45/*
46 The three classes declared in this header represent:
47
48 1. An absolute moment in the time (wxDateTime)
49 2. A difference between two moments in the time, positive or negative
50 (wxTimeSpan)
51 3. A logical difference between two dates expressed in
52 years/months/weeks/days (wxDateSpan)
53
54 The following arithmetic operations are permitted (all others are not):
55
56 addition
57 --------
58
59 wxDateTime + wxTimeSpan = wxDateTime
60 wxDateTime + wxDateSpan = wxDateTime
61 wxTimeSpan + wxTimeSpan = wxTimeSpan
62 wxDateSpan + wxDateSpan = wxDateSpan
63
64 substraction
65 ------------
66 wxDateTime - wxDateTime = wxTimeSpan
67 wxTimeSpan - wxTimeSpan = wxTimeSpan
68 wxDateSpan - wxDateSpan = wxDateSpan
69
70 multiplication
71 --------------
72 wxTimeSpan * number = wxTimeSpan
73 wxDateSpan * number = wxDateSpan
74
75 unitary minus
76 -------------
77 -wxTimeSpan = wxTimeSpan
78 -wxDateSpan = wxDateSpan
79*/
80
81// ----------------------------------------------------------------------------
82// This class represents an absolute moment in the time
83// ----------------------------------------------------------------------------
b76b015e 84
0979c962
VZ
85class WXDLLEXPORT wxDateTime
86{
87public:
88 // types
89 // ------------------------------------------------------------------------
90
91 // a small unsigned integer type for storing things like seconds, days
92 // of the week, &c. It should be at least short (i.e. not char) to
93 // contain the number of milliseconds - it may also be 'int' because
94 // there is no size penalty associated with it in our code, we don't
95 // store any data in this format
96 typedef unsigned short wxDateTime_t;
97
98 // the timezones
b76b015e 99 enum TZ
0979c962
VZ
100 {
101 // the time in the current time zone
102 Local,
103
104 // zones from GMT (= Greenwhich Mean Time): they're guaranteed to be
105 // consequent numbers, so writing something like `GMT0 + offset' is
106 // safe if abs(offset) <= 12
107
108 // underscore stands for minus
109 GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7,
110 GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
111 GMT0,
112 GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
113 GMT7, GMT8, GMT9, GMT10, GMT11, GMT12,
114 // Note that GMT12 and GMT_12 are not the same: there is a difference
115 // of exactly one day between them
116
117 // Universal Coordinated Time
118 UTC = GMT0
119
120 // TODO add symbolic names for TZ (EST, MET, ...)?
121 };
122
123 // the calendar systems we know about: notice that it's valid (for
124 // this classes purpose anyhow) to work with any of these calendars
125 // even with the dates before the historical appearance of the
126 // calendar
127 enum Calendar
128 {
129 Gregorian, // current calendar
130 Julian // calendar in use since -45 until the 1582 (or later)
131
132 // TODO Hebrew, Chinese, Maya, ... (just kidding) (or then may be not?)
133 };
134
135 // these values only are used to identify the different dates of
136 // adoption of the Gregorian calendar (see IsGregorian())
137 //
138 // All data and comments taken verbatim from "The Calendar FAQ (v 2.0)"
139