]> code.citadel.org Git - citadel.git/blob - rss2ctdl/rdf_parsedate.c
6e794c335e68689ade20e96f8ace945c52b40202
[citadel.git] / rss2ctdl / rdf_parsedate.c
1 /*
2  * $id: $
3  *
4  * Convert RDF style datestamps (2005-09-17T06:18:00+00:00) into time_t
5  *
6  */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <sys/types.h>
11 #include <ctype.h>
12 #include <time.h>
13 #include <string.h>
14
15 #include "rdf_parsedate.h"
16
17
18
19 time_t rdf_parsedate(char *p)
20 {
21         struct tm tm;
22
23         if (!p) return 0L;
24         if (strlen(p) < 10) return 0L;
25
26         memset(&tm, 0, sizeof tm);
27
28         /* We only extract the date.  Time is not needed
29          * because we don't need that much granularity.
30          */
31         tm.tm_year = atoi(&p[0]) - 1900;
32         tm.tm_mon = atoi(&p[5]);
33         tm.tm_mday = atoi(&p[8]);
34
35         return mktime(&tm);
36 }