summaryrefslogtreecommitdiffstats
path: root/cython
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2020-04-13 23:21:15 +0200
committerGravatar Nikias Bassen2020-04-13 23:21:15 +0200
commite7355a408a305d0a9aba7c30bbd5a33d978a03c7 (patch)
treeb004c0a4ce6f1a5629dca2be01ec99242df08645 /cython
parent25ab3ae7a474e4d7f165d62865552359b8773860 (diff)
downloadlibplist-e7355a408a305d0a9aba7c30bbd5a33d978a03c7.tar.gz
libplist-e7355a408a305d0a9aba7c30bbd5a33d978a03c7.tar.bz2
cython: Fix handling of Date nodes (needs MACH_EPOCH)
Diffstat (limited to 'cython')
-rw-r--r--cython/plist.pyx4
1 files changed, 4 insertions, 0 deletions
diff --git a/cython/plist.pyx b/cython/plist.pyx
index 0149ffa..be3fe8a 100644
--- a/cython/plist.pyx
+++ b/cython/plist.pyx
@@ -457,6 +457,8 @@ cdef String String_factory(plist_t c_node, bint managed=True):
instance._c_node = c_node
return instance
+MAC_EPOCH = 978307200
+
cdef extern from "plist_util.h":
void datetime_to_ints(object obj, int32_t* sec, int32_t* usec)
object ints_to_datetime(int32_t sec, int32_t usec)
@@ -470,6 +472,7 @@ cdef plist_t create_date_plist(value=None):
node = plist_new_date(0, 0)
elif check_datetime(value):
datetime_to_ints(value, &secs, &usecs)
+ secs -= MAC_EPOCH
node = plist_new_date(secs, usecs)
return node
@@ -500,6 +503,7 @@ cdef class Date(Node):
cdef int32_t secs = 0
cdef int32_t usecs = 0
plist_get_date_val(self._c_node, &secs, &usecs)
+ secs += MAC_EPOCH
return ints_to_datetime(secs, usecs)
cpdef set_value(self, object value):