chiark / gitweb /
dirmngr: Drop useless housekeeping.
[gnupg2.git] / common / gettime.h
1 /* gettime.h - Wrapper for time functions
2  * Copyright (C) 2010, 2012 Free Software Foundation, Inc.
3  *
4  * This file is part of GnuPG.
5  *
6  * This file is free software; you can redistribute it and/or modify
7  * it under the terms of either
8  *
9  *   - the GNU Lesser General Public License as published by the Free
10  *     Software Foundation; either version 3 of the License, or (at
11  *     your option) any later version.
12  *
13  * or
14  *
15  *   - the GNU General Public License as published by the Free
16  *     Software Foundation; either version 2 of the License, or (at
17  *     your option) any later version.
18  *
19  * or both in parallel, as here.
20  *
21  * This file is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, see <https://www.gnu.org/licenses/>.
28  */
29
30 #ifndef GNUPG_COMMON_GETTIME_H
31 #define GNUPG_COMMON_GETTIME_H
32
33 #include <time.h>      /* We need time_t. */
34 #include <gpg-error.h> /* We need gpg_error_t. */
35
36
37 /* A type to hold the ISO time.  Note that this is the same as
38    the KSBA type ksba_isotime_t. */
39 typedef char gnupg_isotime_t[16];
40
41 time_t gnupg_get_time (void);
42 struct tm *gnupg_gmtime (const time_t *timep, struct tm *result);
43 void   gnupg_get_isotime (gnupg_isotime_t timebuf);
44 void   gnupg_set_time (time_t newtime, int freeze);
45 int    gnupg_faked_time_p (void);
46 u32    make_timestamp (void);
47 char *elapsed_time_string (time_t since, time_t now);
48
49 u32    scan_isodatestr (const char *string);
50 int    isotime_p (const char *string);
51 int    isotime_human_p (const char *string, int date_only);
52 size_t string2isotime (gnupg_isotime_t atime, const char *string);
53 time_t isotime2epoch (const char *string);
54 void   epoch2isotime (gnupg_isotime_t timebuf, time_t atime);
55 int    isodate_human_to_tm (const char *string, struct tm *t);
56 time_t parse_timestamp (const char *timestamp, char **endp);
57 u32    add_days_to_timestamp (u32 stamp, u16 days);
58 const char *strtimevalue (u32 stamp);
59 const char *strtimestamp (u32 stamp); /* GMT */
60 const char *isotimestamp (u32 stamp); /* GMT */
61 const char *asctimestamp (u32 stamp); /* localized */
62 char *rfctimestamp (u32 stamp);       /* RFC format, malloced. */
63 gpg_error_t add_seconds_to_isotime (gnupg_isotime_t atime, int nseconds);
64 gpg_error_t add_days_to_isotime (gnupg_isotime_t atime, int ndays);
65 gpg_error_t check_isotime (const gnupg_isotime_t atime);
66 void dump_isotime (const gnupg_isotime_t atime);
67 void gnupg_copy_time (gnupg_isotime_t d, const gnupg_isotime_t s);
68
69
70 #endif /*GNUPG_COMMON_GETTIME_H*/