summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2014-05-22 20:25:30 +0200
committerGravatar Nikias Bassen2014-05-22 20:25:30 +0200
commitd5e1de67fc641a1b85c9185e504d1488820ca02c (patch)
tree750d8d2da5604ff608dc805b41fd6f8dc61230be
parent1317925ffc18a1fd669e8d008de404a8429ea3cf (diff)
downloadlibplist-d5e1de67fc641a1b85c9185e504d1488820ca02c.tar.gz
libplist-d5e1de67fc641a1b85c9185e504d1488820ca02c.tar.bz2
xplist: Fix PLIST_DATE handling to respect the Mac epoch
-rw-r--r--src/xplist.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/xplist.c b/src/xplist.c
index 200d942..a21ae7f 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -51,6 +51,8 @@
#define XPLIST_ARRAY BAD_CAST("array")
#define XPLIST_DICT BAD_CAST("dict")
+#define MAC_EPOCH 978307200
+
static const char *plist_base = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n\
<plist version=\"1.0\">\n\
@@ -222,7 +224,7 @@ static void node_to_xml(node_t* node, void *xml_struct)
case PLIST_DATE:
tag = XPLIST_DATE;
{
- time_t timev = (time_t)node_data->timeval.tv_sec;
+ time_t timev = (time_t)node_data->timeval.tv_sec + MAC_EPOCH;
struct tm *btime = gmtime(&timev);
if (btime) {
val = (char*)malloc(24);
@@ -404,7 +406,7 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
tm_utc = gmtime(&timev);
timev -= (mktime(tm_utc) - timev);
}
- data->timeval.tv_sec = (long)timev;
+ data->timeval.tv_sec = (long)(timev - MAC_EPOCH);
data->timeval.tv_usec = 0;
data->type = PLIST_DATE;
data->length = sizeof(struct timeval);