]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: _datetime.i | |
3 | // Purpose: SWIG interface for wxDateTime and etc. | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 25-Nov-1998 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | %newgroup | |
18 | ||
19 | %{ | |
20 | #include <wx/datetime.h> | |
21 | %} | |
22 | ||
23 | MAKE_CONST_WXSTRING(DefaultDateTimeFormat); | |
24 | MAKE_CONST_WXSTRING(DefaultTimeSpanFormat); | |
25 | ||
26 | //--------------------------------------------------------------------------- | |
27 | ||
28 | ||
29 | %typemap(in) wxDateTime::TimeZone& (bool temp=false) { | |
30 | $1 = new wxDateTime::TimeZone((wxDateTime::TZ)PyInt_AsLong($input)); | |
31 | temp = true; | |
32 | } | |
33 | %typemap(freearg) wxDateTime::TimeZone& { | |
34 | if (temp$argnum) delete $1; | |
35 | } | |
36 | ||
37 | ||
38 | %{ | |
39 | #define LOCAL_TZ wxDateTime::Local | |
40 | %} | |
41 | ||
42 | ||
43 | // Convert a wxLongLong to a Python Long by getting the hi/lo dwords, then | |
44 | // shifting and oring them together | |
45 | %typemap(out) wxLongLong { | |
46 | PyObject *hi, *lo, *shifter, *shifted; | |
47 | hi = PyLong_FromLong( $1.GetHi() ); | |
48 | lo = PyLong_FromLong( $1.GetLo() ); | |
49 | shifter = PyLong_FromLong(32); | |
50 | shifted = PyNumber_Lshift(hi, shifter); | |
51 | $result = PyNumber_Or(shifted, lo); | |
52 | Py_DECREF(hi); | |
53 | Py_DECREF(lo); | |
54 | Py_DECREF(shifter); | |
55 | Py_DECREF(shifted); | |
56 | } | |
57 | ||
58 | ||
59 | //--------------------------------------------------------------------------- | |
60 | ||
61 | //typedef unsigned short wxDateTime_t; | |
62 | #define wxDateTime_t int | |
63 | ||
64 | // wxDateTime represents an absolute moment in the time | |
65 | class wxDateTime { | |
66 | public: | |
67 | ||
68 | enum TZ | |
69 | { | |
70 | // the time in the current time zone | |
71 | Local, | |
72 | ||
73 | // zones from GMT (= Greenwhich Mean Time): they're guaranteed to be | |
74 | // consequent numbers, so writing something like `GMT0 + offset' is | |
75 | // safe if abs(offset) <= 12 | |
76 | // underscore stands for minus | |
77 | GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7, | |
78 | GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1, | |
79 | GMT0, | |
80 | GMT1, GMT2, GMT3, GMT4, GMT5, GMT6, | |
81 | GMT7, GMT8, GMT9, GMT10, GMT11, GMT12, GMT13, | |
82 | ||
83 | // Europe | |
84 | WET = GMT0, // Western Europe Time | |
85 | WEST = GMT1, // Western Europe Summer Time | |
86 | CET = GMT1, // Central Europe Time | |
87 | CEST = GMT2, // Central Europe Summer Time | |
88 | EET = GMT2, // Eastern Europe Time | |
89 | EEST = GMT3, // Eastern Europe Summer Time | |
90 | MSK = GMT3, // Moscow Time | |
91 | MSD = GMT4, // Moscow Summer Time | |
92 | ||
93 | // US and Canada | |
94 | AST = GMT_4, // Atlantic Standard Time | |
95 | ADT = GMT_3, // Atlantic Daylight Time | |
96 | EST = GMT_5, // Eastern Standard Time | |
97 | EDT = GMT_4, // Eastern Daylight Saving Time | |
98 | CST = GMT_6, // Central Standard Time | |
99 | CDT = GMT_5, // Central Daylight Saving Time | |
100 | MST = GMT_7, // Mountain Standard Time | |
101 | MDT = GMT_6, // Mountain Daylight Saving Time | |
102 | PST = GMT_8, // Pacific Standard Time | |
103 | PDT = GMT_7, // Pacific Daylight Saving Time | |
104 | HST = GMT_10, // Hawaiian Standard Time | |
105 | AKST = GMT_9, // Alaska Standard Time | |
106 | AKDT = GMT_8, // Alaska Daylight Saving Time | |
107 | ||
108 | // Australia | |
109 | ||
110 | A_WST = GMT8, // Western Standard Time | |
111 | A_CST = GMT13 + 1, // Central Standard Time (+9.5) | |
112 | A_EST = GMT10, // Eastern Standard Time | |
113 | A_ESST = GMT11, // Eastern Summer Time | |
114 | ||
115 | // New Zealand | |
116 | NZST = GMT12, // Standard Time | |
117 | NZDT = GMT13, // Daylight Saving Time | |
118 | ||
119 | // Universal Coordinated Time = the new and politically correct name | |
120 | // for GMT | |
121 | UTC = GMT0 | |
122 | }; | |
123 | ||
124 | ||
125 | // the calendar systems we know about: notice that it's valid (for | |
126 | // this classes purpose anyhow) to work with any of these calendars | |
127 | // even with the dates before the historical appearance of the | |
128 | // calendar | |
129 | enum Calendar | |
130 | { | |
131 | Gregorian, // current calendar | |
132 | Julian // calendar in use since -45 until the 1582 (or later) | |
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 |