From: Sylvestre Ledru Date: Mon, 1 Jun 2026 18:00:00 +0000 (+0200) Subject: tests: date: check fixed offset is anchored before relative items X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=56ed0d516e53245cf49e641a1dc20ba80ab94f07;p=thirdparty%2Fcoreutils.git tests: date: check fixed offset is anchored before relative items A fixed-offset keyword such as 'UTC' must anchor the instant before relative items are applied, so that '1970-01-01 UTC N seconds' is exactly N seconds past the epoch even when the local zone observes DST between the epoch and the result. * tests/date/date-tz.sh: Add a relative-seconds-across-DST case. https://github.com/coreutils/coreutils/pull/275 --- diff --git a/tests/date/date-tz.sh b/tests/date/date-tz.sh index 0fd8ac16a6..fb8b657801 100755 --- a/tests/date/date-tz.sh +++ b/tests/date/date-tz.sh @@ -29,4 +29,14 @@ case $? in *) grep '^date: invalid date' err || fail=1 ;; esac +# A fixed-offset keyword (here 'UTC') anchors the instant before relative +# items are applied. With a DST-observing zone the epoch base is in winter +# while the result lands in summer, so adding the seconds must not pick up the +# DST hour: '1970-01-01 UTC N seconds' is always exactly N seconds past the +# epoch, regardless of TZ. +secs=1780318971 +TZ='Europe/Berlin' date -d "1970-01-01 UTC $secs seconds" +%s > out || fail=1 +echo "$secs" > exp +compare exp out || fail=1 + Exit $fail