2010-04-20 13:52:33 +02:00
|
|
|
/* gettime.h - Wrapper for time functions
|
2012-04-25 17:40:48 +02:00
|
|
|
* Copyright (C) 2010, 2012 Free Software Foundation, Inc.
|
2010-04-20 13:52:33 +02:00
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
2015-12-14 09:59:43 +01:00
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of either
|
2010-04-20 13:52:33 +02:00
|
|
|
*
|
2015-12-14 09:59:43 +01:00
|
|
|
* - the GNU Lesser General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 3 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* or
|
|
|
|
*
|
|
|
|
* - the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* or both in parallel, as here.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
2010-04-20 13:52:33 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2010-04-20 13:52:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNUPG_COMMON_GETTIME_H
|
|
|
|
#define GNUPG_COMMON_GETTIME_H
|
|
|
|
|
|
|
|
#include <time.h> /* We need time_t. */
|
|
|
|
#include <gpg-error.h> /* We need gpg_error_t. */
|
2023-10-26 09:59:40 +02:00
|
|
|
#include <stdint.h> /* We use uint64_t. */
|
2010-04-20 13:52:33 +02:00
|
|
|
|
2012-04-25 17:40:48 +02:00
|
|
|
/* A type to hold the ISO time. Note that this is the same as
|
|
|
|
the KSBA type ksba_isotime_t. */
|
2010-04-20 13:52:33 +02:00
|
|
|
typedef char gnupg_isotime_t[16];
|
|
|
|
|
2022-02-18 03:11:12 +01:00
|
|
|
/* Constant string of 16-byte, which is compatible to the type
|
|
|
|
gnupg_iso_time_t. */
|
|
|
|
#define GNUPG_ISOTIME_NONE \
|
|
|
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
|
|
|
2023-10-26 09:59:40 +02:00
|
|
|
#ifndef HAVE_TIMEGM
|
|
|
|
time_t timegm (struct tm *tm);
|
|
|
|
#endif /*!HAVE_TIMEGM*/
|
|
|
|
uint64_t timegm_u64 (struct tm *tm);
|
|
|
|
|
2010-04-20 13:52:33 +02:00
|
|
|
time_t gnupg_get_time (void);
|
2015-04-10 12:24:43 +02:00
|
|
|
struct tm *gnupg_gmtime (const time_t *timep, struct tm *result);
|
2010-04-20 13:52:33 +02:00
|
|
|
void gnupg_get_isotime (gnupg_isotime_t timebuf);
|
|
|
|
void gnupg_set_time (time_t newtime, int freeze);
|
|
|
|
int gnupg_faked_time_p (void);
|
|
|
|
u32 make_timestamp (void);
|
2014-03-18 11:02:50 +01:00
|
|
|
char *elapsed_time_string (time_t since, time_t now);
|
|
|
|
|
2023-10-14 17:06:51 +02:00
|
|
|
u32 scan_secondsstr (const char *string);
|
2010-04-20 13:52:33 +02:00
|
|
|
u32 scan_isodatestr (const char *string);
|
2011-03-01 14:22:41 +01:00
|
|
|
int isotime_p (const char *string);
|
2015-04-10 12:02:31 +02:00
|
|
|
int isotime_human_p (const char *string, int date_only);
|
2011-03-01 14:22:41 +01:00
|
|
|
size_t string2isotime (gnupg_isotime_t atime, const char *string);
|
2010-04-20 13:52:33 +02:00
|
|
|
time_t isotime2epoch (const char *string);
|
2023-10-26 09:59:40 +02:00
|
|
|
uint64_t isotime2epoch_u64 (const char *string);
|
2010-04-20 13:52:33 +02:00
|
|
|
void epoch2isotime (gnupg_isotime_t timebuf, time_t atime);
|
2015-04-10 12:02:31 +02:00
|
|
|
int isodate_human_to_tm (const char *string, struct tm *t);
|
2015-03-23 13:22:48 +01:00
|
|
|
time_t parse_timestamp (const char *timestamp, char **endp);
|
2010-04-20 13:52:33 +02:00
|
|
|
u32 add_days_to_timestamp (u32 stamp, u16 days);
|
|
|
|
const char *strtimevalue (u32 stamp);
|
|
|
|
const char *strtimestamp (u32 stamp); /* GMT */
|
|
|
|
const char *isotimestamp (u32 stamp); /* GMT */
|
|
|
|
const char *asctimestamp (u32 stamp); /* localized */
|
2016-06-28 15:45:53 +02:00
|
|
|
char *rfctimestamp (u32 stamp); /* RFC format, malloced. */
|
2010-04-20 13:52:33 +02:00
|
|
|
gpg_error_t add_seconds_to_isotime (gnupg_isotime_t atime, int nseconds);
|
|
|
|
gpg_error_t add_days_to_isotime (gnupg_isotime_t atime, int ndays);
|
|
|
|
gpg_error_t check_isotime (const gnupg_isotime_t atime);
|
|
|
|
void dump_isotime (const gnupg_isotime_t atime);
|
|
|
|
void gnupg_copy_time (gnupg_isotime_t d, const gnupg_isotime_t s);
|
|
|
|
|
|
|
|
|
|
|
|
#endif /*GNUPG_COMMON_GETTIME_H*/
|