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