blob: 6762865f0c866866577c763e851be83f10e7ffcc [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001#define __NO_ASN_TABLE__
Lev Walkin44212662004-08-19 13:26:54 +00002#include <GeneralizedTime.c>
Lev Walkina460ba32004-10-20 15:40:04 +00003#define __NO_ASN_TABLE__
4#include <UTCTime.c>
Lev Walkin44212662004-08-19 13:26:54 +00005#include <constraints.c>
Lev Walkinf15320b2004-06-03 03:38:44 +00006
7static void
Lev Walkin0aca3852004-08-07 03:51:43 +00008check(char *time_str, time_t sample, int as_gmt) {
Lev Walkinf15320b2004-06-03 03:38:44 +00009 UTCTime_t gt;
10 struct tm tm;
11 time_t tloc;
12
13 gt.buf = time_str;
14 gt.size = strlen(time_str);
15
Lev Walkin0aca3852004-08-07 03:51:43 +000016 tloc = asn_UT2time(&gt, &tm, as_gmt);
Lev Walkinf15320b2004-06-03 03:38:44 +000017 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,
Lev Walkina460ba32004-10-20 15:40:04 +000026 GMTOFF(tm)
Lev Walkinf15320b2004-06-03 03:38:44 +000027 );
28 assert(tloc == sample);
Lev Walkin0aca3852004-08-07 03:51:43 +000029
Lev Walkina460ba32004-10-20 15:40:04 +000030 assert(tloc == -1 || as_gmt == 0 || GMTOFF(tm) == 0);
Lev Walkin0aca3852004-08-07 03:51:43 +000031
32 if(as_gmt) check(time_str, sample, as_gmt);
Lev Walkinf15320b2004-06-03 03:38:44 +000033}
34
35int
36main(int ac, char **av) {
37
Lev Walkin44212662004-08-19 13:26:54 +000038 (void)av;
39
Lev Walkin0aca3852004-08-07 03:51:43 +000040 check("0401250", -1, 0);
41 check("0401250930", -1, 0); /* "Z" or "(+|-)hhmm" required */
42 check("04012509300", -1, 0);
43 check("040125093000-", -1, 0);
44 check("040125093007-0", -1, 0);
45 check("040125093007-080", -1, 0);
46 check("0401250930.01Z", -1, 0);
Lev Walkinf15320b2004-06-03 03:38:44 +000047
Lev Walkin0aca3852004-08-07 03:51:43 +000048 check("040125093007Z", 1075023007, 0);
49 check("040125093007+00", 1075023007, 0);
50 check("040125093007-0800", 1075051807, 0);
Lev Walkinf15320b2004-06-03 03:38:44 +000051
52 if(ac > 1) {
53 /* These will be valid only inside PST time zone */
Lev Walkin0aca3852004-08-07 03:51:43 +000054 check("040125093007", 1075051807, 0);
55 check("040125093000,01", 1075051800, 0);
56 check("040125093000,1234", 1075051800, 0);
Lev Walkinf15320b2004-06-03 03:38:44 +000057 }
58
59 return 0;
60}
Lev Walkin0aca3852004-08-07 03:51:43 +000061
62
63/*
64 * Dummy function.
65 */
66
Lev Walkina9cc46e2004-09-22 16:06:28 +000067asn_enc_rval_t
Lev Walkin5e033762004-09-29 13:26:15 +000068OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *ptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkina9cc46e2004-09-22 16:06:28 +000069 asn_enc_rval_t erval;
Lev Walkin44212662004-08-19 13:26:54 +000070
71 (void)td;
72 (void)ptr;
73 (void)tag_mode;
74 (void)tag;
75 (void)cb;
76 (void)app_key;
77
Lev Walkin0aca3852004-08-07 03:51:43 +000078 return erval;
79}
Lev Walkina9cc46e2004-09-22 16:06:28 +000080
81asn_enc_rval_t
Lev Walkin5e033762004-09-29 13:26:15 +000082OCTET_STRING_encode_xer_ascii(asn_TYPE_descriptor_t *td, void *ptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkina9cc46e2004-09-22 16:06:28 +000083 asn_enc_rval_t erval;
84
85 (void)td;
86 (void)ptr;
87 (void)ilevel;
88 (void)flags;
89 (void)cb;
90 (void)app_key;
91
92 return erval;
93}