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