libidav/utils.c

changeset 158
33237261321e
parent 153
272173064319
child 159
7e0a8912ca25
--- a/libidav/utils.c	Tue Oct 13 12:55:37 2015 +0200
+++ b/libidav/utils.c	Tue Oct 13 13:05:38 2015 +0200
@@ -58,20 +58,29 @@
 
 
 time_t util_parse_creationdate(char *str) {
+    // parse a ISO-8601 date
     // example: 2012-11-29T21:35:35Z
     if(!str) {
         return 0;
     }
-    // TODO
-    return 0;
+    // TODO: implement
+    return -1;
 }
 
 time_t util_parse_lastmodified(char *str) {
+    // parse a rfc-1123 date
     // example: Thu, 29 Nov 2012 21:35:35 GMT
     if(!str) {
         return 0;
     } else {
-        return curl_getdate(str, NULL);
+        time_t result = curl_getdate(str, NULL);
+        if(result == -1) {
+            // some shit server don't comply with the WebDAV standard and
+            // use ISO-8601 dates for lastmodified (e.g. Microsoft Sharepoint)
+            return util_parse_creationdate(str);
+        } else {
+            return result;
+        }
     }
 }
 

mercurial