]> Savannah Git Hosting - gnulib.git/commitdiff
parse-datetime-tests: port to Gnulib mktime
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 6 Jan 2025 04:44:22 +0000 (20:44 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 6 Jan 2025 04:44:57 +0000 (20:44 -0800)
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 <https://bugs.gnu.org/48085> was that
parse_datetime shouldn’t fail.

ChangeLog
tests/test-parse-datetime.c

index 6ee180d2842dc075640fc70004c905f09c22599b..d9819dbc50303ccc3b78b4bde6091f574dbd15bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2025-01-05  Paul Eggert  <eggert@cs.ucla.edu>
 
+       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 <https://bugs.gnu.org/48085> 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:
index a2e9751acd25fa94f4ee6718725921e46b2c0363..546b383c55a7d49df15b2bb3a71030fbd50cc000 100644 (file)
@@ -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.  */