1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

* util.h (gnupg_isotime_t): New.

(gnupg_copy_time): New.

* gettime.c (gnupg_get_isotime): New.
This commit is contained in:
Werner Koch 2003-10-31 12:11:57 +00:00
parent 71d265a684
commit f21638c9e3
3 changed files with 52 additions and 0 deletions

View file

@ -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