diff options
Diffstat (limited to '')
-rw-r--r-- | common/gettime.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/common/gettime.c b/common/gettime.c index a7914d348..ed1d0c819 100644 --- a/common/gettime.c +++ b/common/gettime.c @@ -46,6 +46,32 @@ gnupg_get_time () return current - timewarp; } + +/* Return the current time (possibly faked) in ISO format. */ +void +gnupg_get_isotime (gnupg_isotime_t timebuf) +{ + time_t atime = gnupg_get_time (); + + if (atime < 0) + *timebuf = 0; + else + { + struct tm *tp; +#ifdef HAVE_GMTIME_R + struct tm tmbuf; + + tp = gmtime_r (&atime, &tmbuf); +#else + tp = gmtime (&atime); +#endif + sprintf (timebuf,"%04d%02d%02dT%02d%02d%02d", + 1900 + tp->tm_year, tp->tm_mon+1, tp->tm_mday, + tp->tm_hour, tp->tm_min, tp->tm_sec); + } +} + + /* set the time to NEWTIME so that gnupg_get_time returns a time starting with this one. With FREEZE set to 1 the returned time will never change. Just for completeness, a value of (time_t)-1 |