duration.h
Go to the documentation of this file.
1/*
2 * $Id: duration.h 4341 2011-01-31 15:21:09Z matthijs $
3 *
4 * Copyright (c) 2009 NLNet Labs. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
40#ifndef LDNS_DURATION_H
41#define LDNS_DURATION_H
42
43#include <stdint.h>
44#include <time.h>
45
52{
53 time_t years;
54 time_t months;
55 time_t weeks;
56 time_t days;
57 time_t hours;
58 time_t minutes;
59 time_t seconds;
60};
61
68
77
85
92char* ldns_duration2string(const ldns_duration_type* duration);
93
100time_t ldns_duration2time(const ldns_duration_type* duration);
101
108
109#endif /* LDNS_DURATION_H */
time_t ldns_duration2time(const ldns_duration_type *duration)
Convert a duration to a time.
Definition duration.c:246
void ldns_duration_cleanup(ldns_duration_type *duration)
Clean up duration.
Definition duration.c:274
ldns_duration_type * ldns_duration_create_from_string(const char *str)
Create a duration from string.
Definition duration.c:118
ldns_duration_type * ldns_duration_create(void)
Create a new 'instant' duration.
Definition duration.c:54
char * ldns_duration2string(const ldns_duration_type *duration)
Convert a duration to a string.
Definition duration.c:211
int ldns_duration_compare(const ldns_duration_type *d1, const ldns_duration_type *d2)
Compare durations.
Definition duration.c:78