xref: /netbsd-src/external/mpl/dhcp/bind/dist/lib/isc/unix/include/isc/stdtime.h (revision 4afad4b7fa6d4a0d3dedf41d1587a7250710ae54)
1 /*	$NetBSD: stdtime.h,v 1.1 2024/02/18 20:57:58 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5  *
6  * SPDX-License-Identifier: MPL-2.0
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11  *
12  * See the COPYRIGHT file distributed with this work for additional
13  * information regarding copyright ownership.
14  */
15 
16 #ifndef ISC_STDTIME_H
17 #define ISC_STDTIME_H 1
18 
19 /*! \file */
20 
21 #include <inttypes.h>
22 #include <stdlib.h>
23 
24 #include <isc/lang.h>
25 
26 /*%
27  * It's public information that 'isc_stdtime_t' is an unsigned integral type.
28  * Applications that want maximum portability should not assume anything
29  * about its size.
30  */
31 typedef uint32_t isc_stdtime_t;
32 
33 ISC_LANG_BEGINDECLS
34 /* */
35 void
36 isc_stdtime_get(isc_stdtime_t *t);
37 /*%<
38  * Set 't' to the number of seconds since 00:00:00 UTC, January 1, 1970.
39  *
40  * Requires:
41  *
42  *\li	't' is a valid pointer.
43  */
44 
45 void
46 isc_stdtime_tostring(isc_stdtime_t t, char *out, size_t outlen);
47 /*
48  * Convert 't' into a null-terminated string of the form
49  * "Wed Jun 30 21:49:08 1993". Store the string in the 'out'
50  * buffer.
51  *
52  * Requires:
53  *
54  *	't' is a valid time.
55  *	'out' is a valid pointer.
56  *	'outlen' is at least 26.
57  */
58 
59 #define isc_stdtime_convert32(t, t32p) (*(t32p) = t)
60 /*
61  * Convert the standard time to its 32-bit version.
62  */
63 
64 ISC_LANG_ENDDECLS
65 
66 #endif /* ISC_STDTIME_H */
67