1135446Strhodes/*
2234010Sdougb * Copyright (C) 2004-2007, 2012  Internet Systems Consortium, Inc. ("ISC")
3135446Strhodes * Copyright (C) 1999-2001  Internet Software Consortium.
4135446Strhodes *
5193149Sdougb * Permission to use, copy, modify, and/or distribute this software for any
6135446Strhodes * purpose with or without fee is hereby granted, provided that the above
7135446Strhodes * copyright notice and this permission notice appear in all copies.
8135446Strhodes *
9135446Strhodes * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10135446Strhodes * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11135446Strhodes * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12135446Strhodes * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13135446Strhodes * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14135446Strhodes * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15135446Strhodes * PERFORMANCE OF THIS SOFTWARE.
16135446Strhodes */
17135446Strhodes
18254897Serwin/* $Id: time.h,v 1.19 2012/01/27 23:46:58 tbox Exp $ */
19135446Strhodes
20135446Strhodes#ifndef DNS_TIME_H
21135446Strhodes#define DNS_TIME_H 1
22135446Strhodes
23193149Sdougb/*! \file dns/time.h */
24170222Sdougb
25135446Strhodes/***
26135446Strhodes ***	Imports
27135446Strhodes ***/
28135446Strhodes
29135446Strhodes#include <isc/buffer.h>
30135446Strhodes#include <isc/lang.h>
31135446Strhodes
32135446StrhodesISC_LANG_BEGINDECLS
33135446Strhodes
34135446Strhodes/***
35135446Strhodes ***	Functions
36135446Strhodes ***/
37135446Strhodes
38135446Strhodesisc_result_t
39135446Strhodesdns_time64_fromtext(const char *source, isc_int64_t *target);
40170222Sdougb/*%<
41135446Strhodes * Convert a date and time in YYYYMMDDHHMMSS text format at 'source'
42135446Strhodes * into to a 64-bit count of seconds since Jan 1 1970 0:00 GMT.
43135446Strhodes * Store the count at 'target'.
44135446Strhodes */
45135446Strhodes
46135446Strhodesisc_result_t
47135446Strhodesdns_time32_fromtext(const char *source, isc_uint32_t *target);
48170222Sdougb/*%<
49135446Strhodes * Like dns_time64_fromtext, but returns the second count modulo 2^32
50135446Strhodes * as per RFC2535.
51135446Strhodes */
52135446Strhodes
53135446Strhodes
54135446Strhodesisc_result_t
55135446Strhodesdns_time64_totext(isc_int64_t value, isc_buffer_t *target);
56170222Sdougb/*%<
57135446Strhodes * Convert a 64-bit count of seconds since Jan 1 1970 0:00 GMT into
58135446Strhodes * a YYYYMMDDHHMMSS text representation and append it to 'target'.
59135446Strhodes */
60135446Strhodes
61135446Strhodesisc_result_t
62135446Strhodesdns_time32_totext(isc_uint32_t value, isc_buffer_t *target);
63170222Sdougb/*%<
64135446Strhodes * Like dns_time64_totext, but for a 32-bit cyclic time value.
65135446Strhodes * Of those dates whose counts of seconds since Jan 1 1970 0:00 GMT
66135446Strhodes * are congruent with 'value' modulo 2^32, the one closest to the
67135446Strhodes * current date is chosen.
68135446Strhodes */
69135446Strhodes
70234010Sdougbisc_int64_t
71234010Sdougbdns_time64_from32(isc_uint32_t value);
72234010Sdougb/*%<
73234010Sdougb * Covert a 32-bit cyclic time value into a 64 bit time stamp.
74234010Sdougb */
75234010Sdougb
76135446StrhodesISC_LANG_ENDDECLS
77135446Strhodes
78135446Strhodes#endif /* DNS_TIME_H */
79