1 #define _XOPEN_SOURCE /* for strptime */
2 #include "../test-tools.h"
6 /* Convert UTF-8 @string representation of ISO 8601 date to @time.
7 * XXX: Not all ISO formats are supported */
8 _hidden http_error
_server_datestring2tm(const char *string
, struct tm
*time
) {
10 if (!string
|| !time
) return HTTP_ERROR_SERVER
;
12 /* xsd:date is ISO 8601 string, thus ASCII */
13 offset
= strptime(string
, "%Y-%m-%d", time
);
14 if (offset
&& *offset
== '\0')
15 return HTTP_ERROR_SUCCESS
;
17 offset
= strptime(string
, "%Y%m%d", time
);
18 if (offset
&& *offset
== '\0')
19 return HTTP_ERROR_SUCCESS
;
21 offset
= strptime(string
, "%Y-%j", time
);
22 if (offset
&& *offset
== '\0')
23 return HTTP_ERROR_SUCCESS
;
25 return HTTP_ERROR_SERVER
;