remark release date
[Net-Radio-Location-SUPL-Test.git] / asn1 / GeneralizedTime.h
blob1ea06b0686b1e7df6e1a1c91d3191f5592638141
1 /*-
2 * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
4 */
5 #ifndef _GeneralizedTime_H_
6 #define _GeneralizedTime_H_
8 #include <OCTET_STRING.h>
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
14 typedef OCTET_STRING_t GeneralizedTime_t; /* Implemented via OCTET STRING */
16 extern asn_TYPE_descriptor_t asn_DEF_GeneralizedTime;
18 asn_struct_print_f GeneralizedTime_print;
19 asn_constr_check_f GeneralizedTime_constraint;
20 der_type_encoder_f GeneralizedTime_encode_der;
21 xer_type_encoder_f GeneralizedTime_encode_xer;
23 /***********************
24 * Some handy helpers. *
25 ***********************/
27 struct tm; /* <time.h> */
30 * Convert a GeneralizedTime structure into time_t
31 * and optionally into struct tm.
32 * If as_gmt is given, the resulting _optional_tm4fill will have a GMT zone,
33 * instead of default local one.
34 * On error returns -1 and errno set to EINVAL
36 time_t asn_GT2time(const GeneralizedTime_t *, struct tm *_optional_tm4fill,
37 int as_gmt);
39 /* A version of the above function also returning the fractions of seconds */
40 time_t asn_GT2time_frac(const GeneralizedTime_t *,
41 int *frac_value, int *frac_digits, /* (value / (10 ^ digits)) */
42 struct tm *_optional_tm4fill, int as_gmt);
45 * Another version returning fractions with defined precision
46 * For example, parsing of the time ending with ".1" seconds
47 * with frac_digits=3 (msec) would yield frac_value = 100.
49 time_t asn_GT2time_prec(const GeneralizedTime_t *,
50 int *frac_value, int frac_digits,
51 struct tm *_optional_tm4fill, int as_gmt);
54 * Convert a struct tm into GeneralizedTime.
55 * If _optional_gt is not given, this function will try to allocate one.
56 * If force_gmt is given, the resulting GeneralizedTime will be forced
57 * into a GMT time zone (encoding ends with a "Z").
58 * On error, this function returns 0 and sets errno.
60 GeneralizedTime_t *asn_time2GT(GeneralizedTime_t *_optional_gt,
61 const struct tm *, int force_gmt);
62 GeneralizedTime_t *asn_time2GT_frac(GeneralizedTime_t *_optional_gt,
63 const struct tm *, int frac_value, int frac_digits, int force_gmt);
65 #ifdef __cplusplus
67 #endif
69 #endif /* _GeneralizedTime_H_ */