summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2011-05-29 05:07:33 +0200
committerGravatar Nikias Bassen2011-05-29 05:07:33 +0200
commitbfd8c56c016d97e6845664c7bb2e9b0c65d8cb95 (patch)
tree5a2c5c393d17b844c1e6d13869a4f832c18d4176 /src
parentb82787f145fbc205e539a23715cbd3d11f3cdd9b (diff)
downloadlibplist-bfd8c56c016d97e6845664c7bb2e9b0c65d8cb95.tar.gz
libplist-bfd8c56c016d97e6845664c7bb2e9b0c65d8cb95.tar.bz2
Use simple sscanf for parsing dates if strptime is not available
Diffstat (limited to 'src')
-rw-r--r--src/xplist.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/xplist.c b/src/xplist.c
index f62178e..edce2f9 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -260,6 +260,20 @@ static void node_to_xml(node_t* node, void *xml_struct)
return;
}
+static void parse_date(const char *strval, struct tm *btime)
+{
+ if (!btime) return;
+ memset(btime, 0, sizeof(struct tm));
+ if (!strval) return;
+#ifdef strptime
+ strptime((char*)strval, "%Y-%m-%dT%H:%M:%SZ", btime);
+#else
+ sscanf(strval, "%d-%d-%dT%d:%d:%dZ", &btime->tm_year, &btime->tm_mon, &btime->tm_mday, &btime->tm_hour, &btime->tm_min, &btime->tm_sec);
+ btime->tm_year-=1900;
+ btime->tm_mon--;
+#endif
+}
+
static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
{
xmlNodePtr node = NULL;
@@ -330,8 +344,7 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
time_t time = 0;
if (strlen(strval) >= 11) {
struct tm btime;
- memset(&btime, 0, sizeof(struct tm));
- strptime((char*)strval, "%Y-%m-%dT%H:%M:%SZ", &btime);
+ parse_date((const char*)strval, &btime);
time = mktime(&btime);
}
data->timeval.tv_sec = (long)time;