libidav/utils.c

changeset 158
33237261321e
parent 153
272173064319
child 159
7e0a8912ca25
equal deleted inserted replaced
157:8dccc3063e28 158:33237261321e
56 #include "crypto.h" 56 #include "crypto.h"
57 #include "webdav.h" 57 #include "webdav.h"
58 58
59 59
60 time_t util_parse_creationdate(char *str) { 60 time_t util_parse_creationdate(char *str) {
61 // parse a ISO-8601 date
61 // example: 2012-11-29T21:35:35Z 62 // example: 2012-11-29T21:35:35Z
62 if(!str) { 63 if(!str) {
63 return 0; 64 return 0;
64 } 65 }
65 // TODO 66 // TODO: implement
66 return 0; 67 return -1;
67 } 68 }
68 69
69 time_t util_parse_lastmodified(char *str) { 70 time_t util_parse_lastmodified(char *str) {
71 // parse a rfc-1123 date
70 // example: Thu, 29 Nov 2012 21:35:35 GMT 72 // example: Thu, 29 Nov 2012 21:35:35 GMT
71 if(!str) { 73 if(!str) {
72 return 0; 74 return 0;
73 } else { 75 } else {
74 return curl_getdate(str, NULL); 76 time_t result = curl_getdate(str, NULL);
77 if(result == -1) {
78 // some shit server don't comply with the WebDAV standard and
79 // use ISO-8601 dates for lastmodified (e.g. Microsoft Sharepoint)
80 return util_parse_creationdate(str);
81 } else {
82 return result;
83 }
75 } 84 }
76 } 85 }
77 86
78 int util_getboolean(char *v) { 87 int util_getboolean(char *v) {
79 if(v[0] == 'T' || v[0] == 't') { 88 if(v[0] == 'T' || v[0] == 't') {

mercurial