1
#define __NO_ASN_TABLE__
2
#include <GeneralizedTime.c>
3
#include <constraints.c>
6
check(char *time_str, time_t expect, int as_gmt) {
12
gt.size = strlen(time_str);
14
tloc = asn_GT2time(>, &tm, as_gmt);
15
printf("%s: [%s] -> %ld == %ld\n",
16
as_gmt?"GMT":"ofs", time_str, (long)tloc, (long)expect);
19
printf("\t%04d-%02d-%02dT%02d:%02d:%02d%+03ld%02ld\n",
27
labs(GMTOFF(tm) % 3600)
30
assert(tloc == expect);
33
assert(tloc == -1 || as_gmt == 0 || GMTOFF(tm) == 0);
36
if(!as_gmt) check(time_str, expect, 1);
40
rcheck(time_t tloc, const char *expect, int force_gmt) {
41
GeneralizedTime_t *gt;
44
tmp = localtime_r(&tloc, &tm);
47
gt = asn_time2GT(0, &tm, force_gmt);
50
printf("[%s] vs [%s] (%d)\n",
51
gt->buf, expect, force_gmt);
52
assert(gt->size == (int)strlen(gt->buf));
53
assert(!strcmp(gt->buf, expect));
60
main(int ac, char **av) {
64
check("200401250", -1, 0);
65
check("2004012509300", -1, 0);
66
check("20040125093000-", -1, 0);
67
check("20040125093007-0", -1, 0);
68
check("20040125093007-080", -1, 0);
69
check("200401250930.01Z", -1, 0);
71
/* These six are from X.690:11.7.5 */
72
check("19920520240000Z", -1, 0); /* midnight represented incorrectly */
73
//check("19920622123421.0Z", -1, 0); /* spurious trailing zeros */
74
//check("19920722132100.30Z", -1, 0); /* spurious trailing zeros */
75
check("19920521000000Z", 706406400, 0);
76
check("19920622123421Z", 709216461, 0);
77
check("19920722132100.3Z", 711811260, 0);
79
check("20040125093007Z", 1075023007, 0);
80
check("20040125093007+00", 1075023007, 0);
81
check("20040125093007.01+0000", 1075023007, 0);
82
check("20040125093007,1+0000", 1075023007, 0);
83
check("20040125093007-0800", 1075051807, 0);
85
rcheck(1075023007, "20040125093007Z", 1);
88
/* These will be valid only inside PST time zone */
89
check("20040125093007", 1075051807, 0);
90
check("200401250930", 1075051800, 0);
91
check("20040125093000,01", 1075051800, 0);
92
check("20040125093000,1234", 1075051800, 0);
94
rcheck(1075023007, "20040125013007-0800", 0);
105
OCTET_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) {
106
asn_enc_rval_t erval;
119
OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, void *ptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) {
120
asn_enc_rval_t erval;