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