From e264521aaa0558935a2959f899db2a988fa479ca Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 5 Jan 2025 20:44:22 -0800 Subject: [PATCH] parse-datetime-tests: port to Gnulib mktime MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Problem reported by Pádraig Brady in: https://lists.gnu.org/r/bug-gnulib/2025-01/msg00040.html * tests/test-parse-datetime.c (main): Allow both pedantic and naive interpretation of "now - 35 years", since the main point of the test introfuced to fix was that parse_datetime shouldn’t fail. --- ChangeLog | 8 ++++++++ tests/test-parse-datetime.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ee180d284..d9819dbc50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2025-01-05 Paul Eggert + parse-datetime-tests: port to Gnulib mktime + Problem reported by Pádraig Brady in: + https://lists.gnu.org/r/bug-gnulib/2025-01/msg00040.html + * tests/test-parse-datetime.c (main): Allow both pedantic and + naive interpretation of "now - 35 years", since the main point of + the test introfuced to fix was that + parse_datetime shouldn’t fail. + utimensat: mention Linux kernel bug with CIFS * doc/posix-functions/utimensat.texi (utimensat): Mention Linux kernel bug reported by Bruno Haible in: diff --git a/tests/test-parse-datetime.c b/tests/test-parse-datetime.c index a2e9751acd..546b383c55 100644 --- a/tests/test-parse-datetime.c +++ b/tests/test-parse-datetime.c @@ -415,8 +415,14 @@ main (_GL_UNUSED int argc, char **argv) p = "now - 35 years"; ASSERT (parse_datetime (&result, p, &now)); LOG (p, now, result); - ASSERT (result.tv_sec - == 515107490 - 60 * 60 + (has_leap_seconds ? 13 : 0)); + /* Allow "now - 35 years" to mean either (a) the naive sense + where subtracting 35 years from 2021-04-28 16:24:50 yields + 1986-04-28 16:24:50, or (b) the pedantic sense where it + yields 1986-04-28 15:24:50 (an hour earlier) due to adjusting + for the switch from DST in 2021 to standard time in 1986. */ + time_t naive = 515107490 + (has_leap_seconds ? 13 : 0); + time_t pedantic = naive - 60 * 60; + ASSERT (result.tv_sec == naive || result.tv_sec == pedantic); } /* Check that some "next Monday", "last Wednesday", etc. are correct. */ -- 2.39.5