[pacman-dev] [PATCH] Reformatting log timestamp to include time-zone
allan at archlinux.org
Fri Mar 8 00:31:08 UTC 2019
On 8/3/19 10:17 am, Andrew Gregory wrote:
> On 03/04/19 at 04:46pm, Florian Wehner wrote:
>> The time logged is currently given as localtime without any time-zone
>> information. This is confusing in various scenarios.
>> * If one is travelling across time-zones and the timestamps in the log
>> appear out of order.
>> * Comparing dates with `datediff` gives an offset by the time-zone
>> This patch would reformat the time-stamp to a full ISO-8601 version.
>> It includes the 'T' separating date and time. This could be removed.
>> Old: [2019-03-04 16:15]
>> New: [2019-03-04T16:15-05:00]
>> Signed-off-by: Florian Wehner <florian at whnr.de>
>> 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;
> What is tm_gmtoff? I can't find any mention of it in any
The tm_gmtoff field is derived from BSD and is a GNU library extension;
So we can't use that.
More information about the pacman-dev