# HG changeset patch
# User Mike Becker <universe@uap-core.de>
# Date 1444734338 -7200
# Node ID 33237261321e7bc15fe75c74a904051b2aa64791
# Parent  8dccc3063e285abc7e0569611d6b9b496d10210e
added fallback for util_parse_lastmodified, because some servers incorrectly use ISO-8601 dates for lastmodified - TODO: implement the ISO-8601 parsing

diff -r 8dccc3063e28 -r 33237261321e libidav/utils.c
--- 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;
+        }
     }
 }