Skip to content

Commit b0ebfc5

Browse files
committed
add nanosecond arg
1 parent 10b69f7 commit b0ebfc5

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

Include/datetime.h

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@ extern "C" {
1818
* 5 minute 1 byte, 0-59
1919
* 6 second 1 byte, 0-59
2020
* 7 usecond 3 bytes, 0-999999
21-
* 10
21+
* 10 nsecond 2 bytes, 0-999
22+
* 12
2223
*/
2324

2425
/* # of bytes for year, month, and day. */
2526
#define _PyDateTime_DATE_DATASIZE 4
2627

2728
/* # of bytes for hour, minute, second, and usecond. */
28-
#define _PyDateTime_TIME_DATASIZE 6
29+
#define _PyDateTime_TIME_DATASIZE 8
2930

3031
/* # of bytes for year, month, day, hour, minute, second, and usecond. */
31-
#define _PyDateTime_DATETIME_DATASIZE 10
32+
#define _PyDateTime_DATETIME_DATASIZE 12
3233

3334

3435
typedef struct
@@ -38,6 +39,7 @@ typedef struct
3839
int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
3940
int seconds; /* 0 <= seconds < 24*3600 is invariant */
4041
int microseconds; /* 0 <= microseconds < 1000000 is invariant */
42+
int nanoseconds; /* 0 <= nanoseconds < 1000 is invariant */
4143
} PyDateTime_Delta;
4244

4345
typedef struct
@@ -174,20 +176,20 @@ typedef struct {
174176

175177
/* constructors */
176178
PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
177-
PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,
179+
PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, int,
178180
PyObject*, PyTypeObject*);
179-
PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);
180-
PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
181+
PyObject *(*Time_FromTime)(int, int, int, int, int, PyObject*, PyTypeObject*);
182+
PyObject *(*Delta_FromDelta)(int, int, int, int, int, PyTypeObject*);
181183
PyObject *(*TimeZone_FromTimeZone)(PyObject *offset, PyObject *name);
182184

183185
/* constructors for the DB API */
184186
PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*);
185187
PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*);
186188

187189
/* PEP 495 constructors */
188-
PyObject *(*DateTime_FromDateAndTimeAndFold)(int, int, int, int, int, int, int,
190+
PyObject *(*DateTime_FromDateAndTimeAndFold)(int, int, int, int, int, int, int, int,
189191
PyObject*, int, PyTypeObject*);
190-
PyObject *(*Time_FromTimeAndFold)(int, int, int, int, PyObject*, int, PyTypeObject*);
192+
PyObject *(*Time_FromTimeAndFold)(int, int, int, int, int, PyObject*, int, PyTypeObject*);
191193

192194
} PyDateTime_CAPI;
193195

@@ -229,24 +231,24 @@ static PyDateTime_CAPI *PyDateTimeAPI = NULL;
229231
#define PyDate_FromDate(year, month, day) \
230232
PyDateTimeAPI->Date_FromDate((year), (month), (day), PyDateTimeAPI->DateType)
231233

232-
#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \
234+
#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec, nanosec) \
233235
PyDateTimeAPI->DateTime_FromDateAndTime((year), (month), (day), (hour), \
234-
(min), (sec), (usec), Py_None, PyDateTimeAPI->DateTimeType)
236+
(min), (sec), (usec), Py_None, Py_None, (nanosec), PyDateTimeAPI->DateTimeType)
235237

236-
#define PyDateTime_FromDateAndTimeAndFold(year, month, day, hour, min, sec, usec, fold) \
238+
#define PyDateTime_FromDateAndTimeAndFold(year, month, day, hour, min, sec, usec, nanosec, fold) \
237239
PyDateTimeAPI->DateTime_FromDateAndTimeAndFold((year), (month), (day), (hour), \
238-
(min), (sec), (usec), Py_None, (fold), PyDateTimeAPI->DateTimeType)
240+
(min), (sec), (usec), Py_None, (fold), (nanosec), PyDateTimeAPI->DateTimeType)
239241

240-
#define PyTime_FromTime(hour, minute, second, usecond) \
242+
#define PyTime_FromTime(hour, minute, second, usecond, nanosec) \
241243
PyDateTimeAPI->Time_FromTime((hour), (minute), (second), (usecond), \
242-
Py_None, PyDateTimeAPI->TimeType)
244+
Py_None, Py_None, (nanosec), PyDateTimeAPI->TimeType)
243245

244-
#define PyTime_FromTimeAndFold(hour, minute, second, usecond, fold) \
246+
#define PyTime_FromTimeAndFold(hour, minute, second, usecond, nanosec, fold) \
245247
PyDateTimeAPI->Time_FromTimeAndFold((hour), (minute), (second), (usecond), \
246-
Py_None, (fold), PyDateTimeAPI->TimeType)
248+
Py_None, (fold), (nanosec), PyDateTimeAPI->TimeType)
247249

248-
#define PyDelta_FromDSU(days, seconds, useconds) \
249-
PyDateTimeAPI->Delta_FromDelta((days), (seconds), (useconds), 1, \
250+
#define PyDelta_FromDSU(days, seconds, useconds, nanoseconds) \
251+
PyDateTimeAPI->Delta_FromDelta((days), (seconds), (useconds), (nanoseconds), 1, \
250252
PyDateTimeAPI->DeltaType)
251253

252254
#define PyTimeZone_FromOffset(offset) \

0 commit comments

Comments
 (0)