l10n: Update translation catalogues
[libisds.git] / test / simline / unix.c
blobb9e7276382c433d004f0943b45e60b46dfda2d03
1 #define _XOPEN_SOURCE /* for strptime */
2 #include "../test-tools.h"
3 #include <time.h>
4 #include "http.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) {
9 char *offset;
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;