> On 6. Mar 2019, at 19:35, Allan McRae <[email protected]> wrote: > >> On 5/3/19 7:46 am, Florian Wehner wrote: >> >> Old: [2019-03-04 16:15] >> New: [2019-03-04T16:15-05:00] > > Can we switch from localtime() to gmtime() and just use UTC?
Or like that. If you think this is a better fit for the project! Old: [2019-03-04 16:15] New UTC: [2019-03-04T21:15Z] I’ll prepare a patch tomorrow. >> Signed-off-by: Florian Wehner <[email protected]> >> --- >> lib/libalpm/log.c | 10 ++++++++-- >> 1 file changed, 8 insertions(+), 2 deletions(-) >> >> diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c >> index e46ad3c3..cf869a08 100644 >> --- a/lib/libalpm/log.c >> +++ b/lib/libalpm/log.c >> @@ -20,6 +20,7 @@ >> >> #include <stdio.h> >> #include <stdarg.h> >> +#include <stdlib.h> >> #include <errno.h> >> #include <syslog.h> >> >> @@ -37,12 +38,17 @@ >> static int _alpm_log_leader(FILE *f, const char *prefix) >> { >> time_t t = time(NULL); >> + int tz_h, tz_m; >> struct tm *tm = localtime(&t); >> >> + /* Calculate the timezone offset ±hh:mm */ >> + tz_h = tm->tm_gmtoff/3600; >> + tz_m = abs(tm->tm_gmtoff - (tz_h*3600))/60; >> + >> /* Use ISO-8601 date format */ >> - return fprintf(f, "[%04d-%02d-%02d %02d:%02d] [%s] ", >> + return fprintf(f, "[%04d-%02d-%02dT%02d:%02d%+03d:%02d] [%s] ", >> tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, >> - tm->tm_hour, tm->tm_min, prefix); >> + tm->tm_hour, tm->tm_min, tz_h, tz_m, prefix); >> } >> >> /** A printf-like function for logging. >>
