1 /* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * SPDX-License-Identifier: MPL-2.0 5 * 6 * This Source Code Form is subject to the terms of the Mozilla Public 7 * License, v. 2.0. If a copy of the MPL was not distributed with this 8 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 9 * 10 * See the COPYRIGHT file distributed with this work for additional 11 * information regarding copyright ownership. 12 */ 13 14 #ifndef DNS_TIME_H 15 #define DNS_TIME_H 1 16 17 /*! \file dns/time.h */ 18 19 /*** 20 *** Imports 21 ***/ 22 23 #include <inttypes.h> 24 25 #include <isc/buffer.h> 26 #include <isc/lang.h> 27 28 ISC_LANG_BEGINDECLS 29 30 /*** 31 *** Functions 32 ***/ 33 34 isc_result_t 35 dns_time64_fromtext(const char *source, int64_t *target); 36 /*%< 37 * Convert a date and time in YYYYMMDDHHMMSS text format at 'source' 38 * into to a 64-bit count of seconds since Jan 1 1970 0:00 GMT. 39 * Store the count at 'target'. 40 */ 41 42 isc_result_t 43 dns_time32_fromtext(const char *source, uint32_t *target); 44 /*%< 45 * Like dns_time64_fromtext, but returns the second count modulo 2^32 46 * as per RFC2535. 47 */ 48 49 isc_result_t 50 dns_time64_totext(int64_t value, isc_buffer_t *target); 51 /*%< 52 * Convert a 64-bit count of seconds since Jan 1 1970 0:00 GMT into 53 * a YYYYMMDDHHMMSS text representation and append it to 'target'. 54 */ 55 56 isc_result_t 57 dns_time32_totext(uint32_t value, isc_buffer_t *target); 58 /*%< 59 * Like dns_time64_totext, but for a 32-bit cyclic time value. 60 * Of those dates whose counts of seconds since Jan 1 1970 0:00 GMT 61 * are congruent with 'value' modulo 2^32, the one closest to the 62 * current date is chosen. 63 */ 64 65 int64_t 66 dns_time64_from32(uint32_t value); 67 /*%< 68 * Covert a 32-bit cyclic time value into a 64 bit time stamp. 69 */ 70 71 ISC_LANG_ENDDECLS 72 73 #endif /* DNS_TIME_H */ 74