blob: 3451cffec0f7537ca7f2aa4063dd0f3ea4f24a98 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001#define __NO_ASN_TABLE__
2#include "../GeneralizedTime.c"
3#include "../constraints.c"
4
5static void
6check(char *time_str, time_t sample) {
7 GeneralizedTime_t gt;
8 struct tm tm;
9 time_t tloc;
10
11 gt.buf = time_str;
12 gt.size = strlen(time_str);
13
14 tloc = asn_GT2time(&gt, &tm);
15 printf("[%s] -> %ld == %ld\n", time_str, (long)tloc, (long)sample);
16 if(tloc != -1)
17 printf("\t%d-%d-%dT%02d:%02d:%02d %ld\n",
18 tm.tm_year + 1900,
19 tm.tm_mon + 1,
20 tm.tm_mday,
21 tm.tm_hour,
22 tm.tm_min,
23 tm.tm_sec,
24 tm.tm_gmtoff
25 );
26 assert(tloc == sample);
27}
28
29int
30main(int ac, char **av) {
31
32 check("200401250", -1);
33 check("2004012509300", -1);
34 check("20040125093000-", -1);
35 check("20040125093007-0", -1);
36 check("20040125093007-080", -1);
37 check("200401250930.01Z", -1);
38
39 check("20040125093007Z", 1075023007);
40 check("20040125093007+00", 1075023007);
41 check("20040125093007.01+0000", 1075023007);
42 check("20040125093007,1+0000", 1075023007);
43 check("20040125093007-0800", 1075051807);
44
45 if(ac > 1) {
46 /* These will be valid only inside PST time zone */
47 check("20040125093007", 1075051807);
48 check("200401250930", 1075051800);
49 check("20040125093000,01", 1075051800);
50 check("20040125093000,1234", 1075051800);
51 }
52
53 return 0;
54}