]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Add bstrftime_gmt_iso8601() function
authorEric Bollengier <eric@baculasystems.com>
Tue, 12 Jan 2021 10:02:28 +0000 (11:02 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:59 +0000 (09:02 +0100)
bacula/src/lib/btime.c
bacula/src/lib/btime.h

index 3933012919592e7a4cae1fe8e4e5b31a133658e2..ae61881c63ccf589dda0fdd762cece4d84f39901 100644 (file)
@@ -143,6 +143,17 @@ char *bstrutime(char *dt, int maxlen, utime_t utime)
    return dt;
 }
 
+
+/* Unix time to GMT standard time string yyyy-mm-ddThh:mm:ss.000Z */
+char *bstrftime_gmt_iso8601(char *dt, int maxlen, utime_t utime)
+{
+   time_t time = (time_t)utime;
+   struct tm tm;
+   (void)gmtime_r(&time, &tm);
+   strftime(dt, maxlen, "%Y-%m-%dT%H:%M:%S.000Z", &tm);
+   return dt;
+}
+
 /* Convert standard time string yyyy-mm-dd hh:mm:ss to Unix time */
 utime_t str_to_utime(char *str)
 {
index 3e3579515f892af844fc882e1fbabf0c9a685c0f..b9df3e32cced91d9d2fc028434313fb42d38a474 100644 (file)
@@ -44,7 +44,7 @@ char *bstrftime_dn(char *dt, int maxlen, utime_t tim);
 char *bstrftime_c(char *dt, int maxlen, utime_t utime);
 utime_t str_to_utime(char *str);
 char *bstrftimes_na(char *dt, int maxlen, utime_t utime);
-
+char *bstrftime_gmt_iso8601(char *dt, int maxlen, utime_t utime);
 
 /* =========================================================== */
 /*        old code deprecated below. Do not use.               */