diff options
author | J William Piggott | 2017-10-08 22:06:24 +0200 |
---|---|---|
committer | J William Piggott | 2017-11-10 22:14:04 +0100 |
commit | 9fd0a7a96c8525289d7072fa688579be6418ec30 (patch) | |
tree | d815e9e7b77e2493bbc8768486b988c4c4f7dbca /login-utils/last.c | |
parent | lib/timeutils: ISO_8601_BUFSIZ too small (diff) | |
download | kernel-qcow2-util-linux-9fd0a7a96c8525289d7072fa688579be6418ec30.tar.gz kernel-qcow2-util-linux-9fd0a7a96c8525289d7072fa688579be6418ec30.tar.xz kernel-qcow2-util-linux-9fd0a7a96c8525289d7072fa688579be6418ec30.zip |
lib/timeutils: add get_gmtoff()
This new function returns the GMT offset relative to its
argument. It is used in this patch to fix two bugs:
1) On platforms that the tm struct excludes tm_gmtoff,
hwclock assumes a one hour DST offset. This can cause
an incorrect kernel timezone setting. For example:
Master branch tested with tm_gmtoff illustrates the correct offset:
$ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday
Calling settimeofday(1507494204.192398, -660)
Master branch tested without tm_gmtoff has an incorrect offset:
$ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday
Calling settimeofday(1507494249.193852, -690)
Patched tested without tm_gmtoff has the correct offset:
$ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday
Calling settimeofday(1507494260.194208, -660)
2) ISO 8601 'extended' format requires all time elements
to use a colon (:).
Current invalid ISO 8601:
$ hwclock
2017-10-08 16:25:17.895462-0400
Patched:
$ hwclock
2017-10-08 16:25:34.141895-04:00
Also required by this change:
login-utils/last.c: increase ISO out_len and in_len by one to
accommodate the addition of the timezone colon.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Diffstat (limited to 'login-utils/last.c')
-rw-r--r-- | login-utils/last.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/login-utils/last.c b/login-utils/last.c index f989836ba..f2e8f834e 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -145,8 +145,8 @@ static struct last_timefmt timefmts[] = { }, [LAST_TIMEFTM_ISO8601] = { .name = "iso", - .in_len = 24, - .out_len = 26, + .in_len = 25, + .out_len = 27, .in_fmt = LAST_TIMEFTM_ISO8601, .out_fmt = LAST_TIMEFTM_ISO8601 } |