time.c File Reference

#include <config.h>
#include <stdio.h>
#include <isc/string.h>
#include <time.h>
#include <ctype.h>
#include <isc/print.h>
#include <isc/region.h>
#include <isc/serial.h>
#include <isc/stdtime.h>
#include <isc/util.h>
#include <dns/result.h>

Go to the source code of this file.

Defines

#define is_leap(y)   ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
#define year_secs(y)   ((is_leap(y) ? 366 : 365 ) * 86400)
#define month_secs(m, y)   ((days[m] + ((m == 1 && is_leap(y)) ? 1 : 0 )) * 86400)
#define RANGE(min, max, value)

Functions

isc_result_t dns_time64_totext (isc_int64_t t, isc_buffer_t *target)
 Convert a 64-bit count of seconds since Jan 1 1970 0:00 GMT into a YYYYMMDDHHMMSS text representation and append it to 'target'.
isc_int64_t dns_time64_from32 (isc_uint32_t value)
 Covert a 32-bit cyclic time value into a 64 bit time stamp.
isc_result_t dns_time32_totext (isc_uint32_t value, isc_buffer_t *target)
 Like dns_time64_totext, but for a 32-bit cyclic time value. Of those dates whose counts of seconds since Jan 1 1970 0:00 GMT are congruent with 'value' modulo 2^32, the one closest to the current date is chosen.
isc_result_t dns_time64_fromtext (const char *source, isc_int64_t *target)
 Convert a date and time in YYYYMMDDHHMMSS text format at 'source' into to a 64-bit count of seconds since Jan 1 1970 0:00 GMT. Store the count at 'target'.
isc_result_t dns_time32_fromtext (const char *source, isc_uint32_t *target)
 Like dns_time64_fromtext, but returns the second count modulo 2^32 as per RFC2535.

Variables

static const int days [12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }


Detailed Description

Definition in file time.c.


Define Documentation

#define is_leap (  )     ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)

Referenced by dns_time64_fromtext().

#define year_secs (  )     ((is_leap(y) ? 366 : 365 ) * 86400)

Referenced by dns_time64_totext().

#define month_secs ( m,
 )     ((days[m] + ((m == 1 && is_leap(y)) ? 1 : 0 )) * 86400)

Referenced by dns_time64_totext().

#define RANGE ( min,
max,
value   ) 

Value:

do { \
                if (value < (min) || value > (max)) \
                        return (ISC_R_RANGE); \
        } while (0)

Referenced by dns_time64_fromtext(), stub_callback(), zone_postload(), and zone_xfrdone().


Function Documentation

isc_result_t dns_time64_totext ( isc_int64_t  t,
isc_buffer_t target 
)

Convert a 64-bit count of seconds since Jan 1 1970 0:00 GMT into a YYYYMMDDHHMMSS text representation and append it to 'target'.

Definition at line 41 of file time.c.

References isc_region::base, isc_buffer_add, isc_buffer_availableregion, ISC_R_NOSPACE, ISC_R_RANGE, ISC_R_SUCCESS, isc_region::length, month_secs, and year_secs.

Referenced by dns_time32_totext(), and dump_rdatasets_text().

isc_int64_t dns_time64_from32 ( isc_uint32_t  value  ) 

Covert a 32-bit cyclic time value into a 64 bit time stamp.

Definition at line 107 of file time.c.

References isc_serial_gt(), isc_stdtime_get(), now, and start.

Referenced by del_sigs(), and dns_time32_totext().

isc_result_t dns_time32_totext ( isc_uint32_t  value,
isc_buffer_t target 
)

Like dns_time64_totext, but for a 32-bit cyclic time value. Of those dates whose counts of seconds since Jan 1 1970 0:00 GMT are congruent with 'value' modulo 2^32, the one closest to the current date is chosen.

Definition at line 129 of file time.c.

References dns_time64_from32(), and dns_time64_totext().

Referenced by ATF_TC_BODY(), dns_ntatable_save(), dst__privstruct_writefile(), printtime(), totext_keydata(), totext_rrsig(), totext_sig(), and writeheader().

isc_result_t dns_time64_fromtext ( const char *  source,
isc_int64_t target 
)

Convert a date and time in YYYYMMDDHHMMSS text format at 'source' into to a 64-bit count of seconds since Jan 1 1970 0:00 GMT. Store the count at 'target'.

Definition at line 134 of file time.c.

References day, days, DNS_R_SYNTAX, is_leap, ISC_R_SUCCESS, and RANGE.

Referenced by dns_time32_fromtext(), load_text(), and strtotime().

isc_result_t dns_time32_fromtext ( const char *  source,
isc_uint32_t target 
)

Like dns_time64_fromtext, but returns the second count modulo 2^32 as per RFC2535.

Definition at line 202 of file time.c.

References dns_time64_fromtext(), and ISC_R_SUCCESS.

Referenced by ATF_TC_BODY(), dns_view_loadnta(), dst__privstruct_parse(), fromtext_keydata(), fromtext_rrsig(), and fromtext_sig().


Variable Documentation

const int days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } [static]

Definition at line 38 of file time.c.

Referenced by dns_time64_fromtext(), and dns_ttl_totext2().


Generated on Tue Apr 28 17:41:19 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha