annotate Include/datetime.h @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 61227b4c169f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
1 /* datetime.h
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
2 */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 65494
diff changeset
3 #ifndef Py_LIMITED_API
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
4 #ifndef DATETIME_H
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
5 #define DATETIME_H
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
6 #ifdef __cplusplus
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
7 extern "C" {
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
8 #endif
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
9
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
10 /* Fields are packed into successive bytes, each viewed as unsigned and
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
11 * big-endian, unless otherwise noted:
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
12 *
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
13 * byte offset
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
14 * 0 year 2 bytes, 1-9999
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
15 * 2 month 1 byte, 1-12
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
16 * 3 day 1 byte, 1-31
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
17 * 4 hour 1 byte, 0-23
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
18 * 5 minute 1 byte, 0-59
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
19 * 6 second 1 byte, 0-59
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
20 * 7 usecond 3 bytes, 0-999999
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
21 * 10
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
22 */
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
23
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
24 /* # of bytes for year, month, and day. */
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
25 #define _PyDateTime_DATE_DATASIZE 4
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
26
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
27 /* # of bytes for hour, minute, second, and usecond. */
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
28 #define _PyDateTime_TIME_DATASIZE 6
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
29
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
30 /* # of bytes for year, month, day, hour, minute, second, and usecond. */
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
31 #define _PyDateTime_DATETIME_DATASIZE 10
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
32
27217
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
33
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
34 typedef struct
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
35 {
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
36 PyObject_HEAD
65494
e8969fb822fc make hashes always the size of pointers; introduce Py_hash_t #9778
Benjamin Peterson <benjamin@python.org>
parents: 61466
diff changeset
37 Py_hash_t hashcode; /* -1 when unknown */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
38 int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
39 int seconds; /* 0 <= seconds < 24*3600 is invariant */
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
40 int microseconds; /* 0 <= microseconds < 1000000 is invariant */
27217
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
41 } PyDateTime_Delta;
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
42
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
43 typedef struct
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
44 {
85231
61227b4c169f #18466: fix more typos. Patch by Févry Thibault.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 74470
diff changeset
45 PyObject_HEAD /* a pure abstract base class */
27217
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
46 } PyDateTime_TZInfo;
27195
65dc0110a735 Got rid of the timetz type entirely. This was a bit trickier than I
Tim Peters <tim.peters@gmail.com>
parents: 26673
diff changeset
47
27217
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
48
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
49 /* The datetime and time types have hashcodes, and an optional tzinfo member,
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
50 * present if and only if hastzinfo is true.
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
51 */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
52 #define _PyTZINFO_HEAD \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
53 PyObject_HEAD \
65494
e8969fb822fc make hashes always the size of pointers; introduce Py_hash_t #9778
Benjamin Peterson <benjamin@python.org>
parents: 61466
diff changeset
54 Py_hash_t hashcode; \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
55 char hastzinfo; /* boolean flag */
27217
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
56
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
57 /* No _PyDateTime_BaseTZInfo is allocated; it's just to have something
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
58 * convenient to cast to, when getting at the hastzinfo member of objects
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
59 * starting with _PyTZINFO_HEAD.
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
60 */
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
61 typedef struct
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
62 {
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
63 _PyTZINFO_HEAD
27217
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
64 } _PyDateTime_BaseTZInfo;
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
65
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
66 /* All time objects are of PyDateTime_TimeType, but that can be allocated
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
67 * in two ways, with or without a tzinfo member. Without is the same as
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
68 * tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
69 * internal struct used to allocate the right amount of space for the
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
70 * "without" case.
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
71 */
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
72 #define _PyDateTime_TIMEHEAD \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
73 _PyTZINFO_HEAD \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
74 unsigned char data[_PyDateTime_TIME_DATASIZE];
27217
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
75
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
76 typedef struct
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
77 {
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
78 _PyDateTime_TIMEHEAD
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
79 } _PyDateTime_BaseTime; /* hastzinfo false */
27217
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
80
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
81 typedef struct
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
82 {
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
83 _PyDateTime_TIMEHEAD
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
84 PyObject *tzinfo;
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
85 } PyDateTime_Time; /* hastzinfo true */
27217
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
86
27218
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
87
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
88 /* All datetime objects are of PyDateTime_DateTimeType, but that can be
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
89 * allocated in two ways too, just like for time objects above. In addition,
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
90 * the plain date type is a base class for datetime, so it must also have
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
91 * a hastzinfo member (although it's unused there).
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
92 */
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
93 typedef struct
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
94 {
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
95 _PyTZINFO_HEAD
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
96 unsigned char data[_PyDateTime_DATE_DATASIZE];
27218
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
97 } PyDateTime_Date;
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
98
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
99 #define _PyDateTime_DATETIMEHEAD \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
100 _PyTZINFO_HEAD \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
101 unsigned char data[_PyDateTime_DATETIME_DATASIZE];
27217
10b7e60245b5 Minor fiddling to make the next part easier. Introduced an internal
Tim Peters <tim.peters@gmail.com>
parents: 27195
diff changeset
102
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
103 typedef struct
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
104 {
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
105 _PyDateTime_DATETIMEHEAD
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
106 } _PyDateTime_BaseDateTime; /* hastzinfo false */
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
107
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
108 typedef struct
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
109 {
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
110 _PyDateTime_DATETIMEHEAD
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
111 PyObject *tzinfo;
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
112 } PyDateTime_DateTime; /* hastzinfo true */
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
113
27195
65dc0110a735 Got rid of the timetz type entirely. This was a bit trickier than I
Tim Peters <tim.peters@gmail.com>
parents: 26673
diff changeset
114
27218
38d2238c795e Got rid of the internal datetimetz type.
Tim Peters <tim.peters@gmail.com>
parents: 27217
diff changeset
115 /* Apply for date and datetime instances. */
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
116 #define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
117 ((PyDateTime_Date*)o)->data[1])
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
118 #define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2])
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
119 #define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3])
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
120
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
121 #define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4])
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
122 #define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5])
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
123 #define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6])
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
124 #define PyDateTime_DATE_GET_MICROSECOND(o) \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
125 ((((PyDateTime_DateTime*)o)->data[7] << 16) | \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
126 (((PyDateTime_DateTime*)o)->data[8] << 8) | \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
127 ((PyDateTime_DateTime*)o)->data[9])
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
128
27195
65dc0110a735 Got rid of the timetz type entirely. This was a bit trickier than I
Tim Peters <tim.peters@gmail.com>
parents: 26673
diff changeset
129 /* Apply for time instances. */
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
130 #define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0])
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
131 #define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1])
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
132 #define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2])
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
133 #define PyDateTime_TIME_GET_MICROSECOND(o) \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
134 ((((PyDateTime_Time*)o)->data[3] << 16) | \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
135 (((PyDateTime_Time*)o)->data[4] << 8) | \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
136 ((PyDateTime_Time*)o)->data[5])
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
137
74470
463acb73fd79 Issue #13727: Add 3 macros to access PyDateTime_Delta members:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 68257
diff changeset
138 /* Apply for time delta instances */
463acb73fd79 Issue #13727: Add 3 macros to access PyDateTime_Delta members:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 68257
diff changeset
139 #define PyDateTime_DELTA_GET_DAYS(o) (((PyDateTime_Delta*)o)->days)
463acb73fd79 Issue #13727: Add 3 macros to access PyDateTime_Delta members:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 68257
diff changeset
140 #define PyDateTime_DELTA_GET_SECONDS(o) (((PyDateTime_Delta*)o)->seconds)
463acb73fd79 Issue #13727: Add 3 macros to access PyDateTime_Delta members:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 68257
diff changeset
141 #define PyDateTime_DELTA_GET_MICROSECONDS(o) \
463acb73fd79 Issue #13727: Add 3 macros to access PyDateTime_Delta members:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 68257
diff changeset
142 (((PyDateTime_Delta*)o)->microseconds)
463acb73fd79 Issue #13727: Add 3 macros to access PyDateTime_Delta members:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 68257
diff changeset
143
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
144
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
145 /* Define structure for C API. */
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
146 typedef struct {
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
147 /* type objects */
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
148 PyTypeObject *DateType;
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
149 PyTypeObject *DateTimeType;
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
150 PyTypeObject *TimeType;
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
151 PyTypeObject *DeltaType;
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
152 PyTypeObject *TZInfoType;
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
153
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
154 /* constructors */
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
155 PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
156 PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
157 PyObject*, PyTypeObject*);
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
158 PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
159 PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
160
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
161 /* constructors for the DB API */
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
162 PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*);
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
163 PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*);
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
164
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
165 } PyDateTime_CAPI;
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
166
53816
911df82bc25d add a replacement API for PyCObject, PyCapsule #5630
Benjamin Peterson <benjamin@python.org>
parents: 44351
diff changeset
167 #define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI"
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
168
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
169
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
170 #ifdef Py_BUILD_CORE
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
171
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
172 /* Macros for type checking when building the Python core. */
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
173 #define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
174 #define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType)
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
175
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
176 #define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
177 #define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType)
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
178
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
179 #define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
180 #define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType)
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
181
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
182 #define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
183 #define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType)
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
184
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
185 #define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
186 #define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType)
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
187
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
188 #else
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
189
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
190 /* Define global variable for the C API and a macro for setting it. */
57723
7705ac218c87 Merged revisions 76822,76824 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 53816
diff changeset
191 static PyDateTime_CAPI *PyDateTimeAPI = NULL;
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
192
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
193 #define PyDateTime_IMPORT \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
194 PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
195
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
196 /* Macros for type checking when not building the Python core. */
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
197 #define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
198 #define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
199
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
200 #define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
201 #define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
202
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
203 #define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
204 #define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
205
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
206 #define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
207 #define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
208
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
209 #define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
210 #define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
211
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
212 /* Macros for accessing constructors in a simplified fashion. */
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
213 #define PyDate_FromDate(year, month, day) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
214 PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
215
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
216 #define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
217 PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
218 min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
219
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
220 #define PyTime_FromTime(hour, minute, second, usecond) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
221 PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
222 Py_None, PyDateTimeAPI->TimeType)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
223
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
224 #define PyDelta_FromDSU(days, seconds, useconds) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
225 PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
226 PyDateTimeAPI->DeltaType)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
227
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
228 /* Macros supporting the DB API. */
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
229 #define PyDateTime_FromTimestamp(args) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
230 PyDateTimeAPI->DateTime_FromTimestamp( \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
231 (PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
232
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
233 #define PyDate_FromTimestamp(args) \
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
234 PyDateTimeAPI->Date_FromTimestamp( \
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
235 (PyObject*) (PyDateTimeAPI->DateType), args)
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
236
61467
f197407bdba2 Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 53816
diff changeset
237 #endif /* Py_BUILD_CORE */
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
238
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
239 #ifdef __cplusplus
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
240 }
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
241 #endif
32393
e5df8c8faa09 SF patch 876130: add C API to datetime module, from Anthony Tuininga.
Tim Peters <tim.peters@gmail.com>
parents: 27218
diff changeset
242 #endif
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 65494
diff changeset
243 #endif /* !Py_LIMITED_API */