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