summaryrefslogtreecommitdiffstats
path: root/common/gettime.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2003-10-31 13:11:57 +0100
committerWerner Koch <wk@gnupg.org>2003-10-31 13:11:57 +0100
commitf21638c9e3b614bc0be6903b1fb75543f9619a7b (patch)
treea5420a9b4af866391297f917721640dbd89f7380 /common/gettime.c
parent* command.c (cmd_get_confirmation): New command. (diff)
downloadgnupg2-f21638c9e3b614bc0be6903b1fb75543f9619a7b.tar.xz
gnupg2-f21638c9e3b614bc0be6903b1fb75543f9619a7b.zip
* util.h (gnupg_isotime_t): New.
(gnupg_copy_time): New. * gettime.c (gnupg_get_isotime): New.
Diffstat (limited to 'common/gettime.c')
-rw-r--r--common/gettime.c26
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