Commit 76646102 authored by zaur's avatar zaur

Fix inline getters for timedelta

parent d6bb5f89
...@@ -25,16 +25,20 @@ cdef extern from "datetime.h": ...@@ -25,16 +25,20 @@ cdef extern from "datetime.h":
pass pass
ctypedef struct PyDateTime_Time: ctypedef struct PyDateTime_Time:
char hastzinfo # boolean flag char hastzinfo
PyObject *tzinfo PyObject *tzinfo
ctypedef struct PyDateTime_DateTime: ctypedef struct PyDateTime_DateTime:
char hastzinfo # boolean flag char hastzinfo
PyObject *tzinfo PyObject *tzinfo
ctypedef struct PyDateTime_Delta:
int days
int seconds
int microseconds
# Define structure for C API. # Define structure for C API.
ctypedef struct PyDateTime_CAPI: ctypedef struct PyDateTime_CAPI:
long hashcode
# type objects # type objects
PyTypeObject *DateType PyTypeObject *DateType
PyTypeObject *DateTimeType PyTypeObject *DateTimeType
...@@ -86,9 +90,9 @@ cdef extern from "datetime.h": ...@@ -86,9 +90,9 @@ cdef extern from "datetime.h":
int PyDateTime_TIME_GET_MICROSECOND(object o) int PyDateTime_TIME_GET_MICROSECOND(object o)
# Getters for timedelta (C macros). # Getters for timedelta (C macros).
int PyDateTime_DELTA_GET_DAYS(object o) #int PyDateTime_DELTA_GET_DAYS(object o)
int PyDateTime_DELTA_GET_SECONDS(object o) #int PyDateTime_DELTA_GET_SECONDS(object o)
int PyDateTime_DELTA_GET_MICROSECONDS(object o) #int PyDateTime_DELTA_GET_MICROSECONDS(object o)
# PyDateTime CAPI object. # PyDateTime CAPI object.
PyDateTime_CAPI *PyDateTimeAPI PyDateTime_CAPI *PyDateTimeAPI
...@@ -195,12 +199,12 @@ cdef inline int datetime_microsecond(object o): ...@@ -195,12 +199,12 @@ cdef inline int datetime_microsecond(object o):
# Get days of timedelta # Get days of timedelta
cdef inline int timedelta_days(object o): cdef inline int timedelta_days(object o):
return PyDateTime_DELTA_GET_DAYS(o) return (<PyDateTime_Delta*>o).days
# Get seconds of timedelta # Get seconds of timedelta
cdef inline int timedelta_seconds(object o): cdef inline int timedelta_seconds(object o):
return PyDateTime_DELTA_GET_SECONDS(o) return (<PyDateTime_Delta*>o).seconds
# Get microseconds of timedelta # Get microseconds of timedelta
cdef inline int timedelta_microseconds(object o): cdef inline int timedelta_microseconds(object o):
return PyDateTime_DELTA_GET_MICROSECONDS(o) return (<PyDateTime_Delta*>o).microseconds
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment