1 /* $NetBSD: time.h,v 1.4 2014/12/10 04:37:58 christos Exp $ */ 2 3 /* 4 * Copyright (C) 2004-2007, 2012 Internet Systems Consortium, Inc. ("ISC") 5 * Copyright (C) 1999-2001 Internet Software Consortium. 6 * 7 * Permission to use, copy, modify, and/or distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /* Id: time.h,v 1.19 2012/01/27 23:46:58 tbox Exp */ 21 22 #ifndef DNS_TIME_H 23 #define DNS_TIME_H 1 24 25 /*! \file dns/time.h */ 26 27 /*** 28 *** Imports 29 ***/ 30 31 #include <isc/buffer.h> 32 #include <isc/lang.h> 33 34 ISC_LANG_BEGINDECLS 35 36 /*** 37 *** Functions 38 ***/ 39 40 isc_result_t 41 dns_time64_fromtext(const char *source, isc_int64_t *target); 42 /*%< 43 * Convert a date and time in YYYYMMDDHHMMSS text format at 'source' 44 * into to a 64-bit count of seconds since Jan 1 1970 0:00 GMT. 45 * Store the count at 'target'. 46 */ 47 48 isc_result_t 49 dns_time32_fromtext(const char *source, isc_uint32_t *target); 50 /*%< 51 * Like dns_time64_fromtext, but returns the second count modulo 2^32 52 * as per RFC2535. 53 */ 54 55 56 isc_result_t 57 dns_time64_totext(isc_int64_t value, isc_buffer_t *target); 58 /*%< 59 * Convert a 64-bit count of seconds since Jan 1 1970 0:00 GMT into 60 * a YYYYMMDDHHMMSS text representation and append it to 'target'. 61 */ 62 63 isc_result_t 64 dns_time32_totext(isc_uint32_t value, isc_buffer_t *target); 65 /*%< 66 * Like dns_time64_totext, but for a 32-bit cyclic time value. 67 * Of those dates whose counts of seconds since Jan 1 1970 0:00 GMT 68 * are congruent with 'value' modulo 2^32, the one closest to the 69 * current date is chosen. 70 */ 71 72 isc_int64_t 73 dns_time64_from32(isc_uint32_t value); 74 /*%< 75 * Covert a 32-bit cyclic time value into a 64 bit time stamp. 76 */ 77 78 ISC_LANG_ENDDECLS 79 80 #endif /* DNS_TIME_H */ 81