blob: cce735d3aef2638fefaa41af51636bcebc5dc5f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/* ISC license. */
#include <errno.h>
#include <time.h>
#include <skalibs/djbtime.h>
#include <tipidee/util.h>
int tipidee_util_httpdate (char const *s, tain *stamp)
{
struct tm tm ;
if (strptime(s, "%a, %d %b %Y %T GMT", &tm)) goto got ;
if (strptime(s, "%a, %d-%b-%y %T GMT", &tm)) goto got ;
if (strptime(s, "%a %b %d %T %Y", &tm)) goto got ;
return (errno = EINVAL, 0) ;
got:
if (!tai_from_localtm(tain_secp(stamp), &tm)) return 0 ;
stamp->nano = 0 ;
return 1 ;
}
|