From: Collin Funk Date: Sun, 14 Dec 2025 20:37:41 +0000 (-0800) Subject: tests: date: add another locale test case X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45071c85b54d5ff74d1d48b8738dc2b33869e432;p=thirdparty%2Fcoreutils.git tests: date: add another locale test case On a GNU/Linux system, we have the following: $ LC_ALL=en_US.UTF-8 date -u -d 1:00 Sun Dec 14 01:00:00 AM UTC 2025 $ LC_ALL=en_US.UTF-8 locale date_fmt %a %b %e %r %Z %Y $ LC_ALL=en_US.UTF-8 locale t_fmt_ampm %I:%M:%S %p $ LC_ALL=nl_NL.UTF-8 date -u -d 1:00 zo 14 dec 2025 1:00:00 UTC $ LC_ALL=nl_NL.UTF-8 locale date_fmt %a %e %b %Y %k:%M:%S %Z We respect the locales preference for a leading zero or leading space in single digit hours. * tests/date/date-locale-hour.sh: Check that the locales preference for leading zeros or spaces in single digit hours is used. --- diff --git a/tests/date/date-locale-hour.sh b/tests/date/date-locale-hour.sh index 7e0d12019c..409091080c 100755 --- a/tests/date/date-locale-hour.sh +++ b/tests/date/date-locale-hour.sh @@ -34,6 +34,26 @@ for loc in "$LOCALE_FR_UTF8" 'en_US.UTF-8'; do *"$compare_time"*) ;; *) fail=1 ;; esac + + # The use of %r requires checking 'locale t_fmt_ampm' for the format. + # The use of %X requires checking 'locale t_fmt' for the format. + fmt=$(LC_ALL="$loc" locale date_fmt) + case "$fmt" in + *%r*) fmt=$(LC_ALL="$loc" locale t_fmt_ampm) ;; + *%X*) fmt=$(LC_ALL="$loc" locale t_fmt) ;; + esac + + case "$fmt" in + *%[IHRT]*) compare_time='01:00' ;; + *%_[IH]*) compare_time=' 1:00' ;; + *%[lk]*) compare_time=' 1:00' ;; + *) skip_ 'unrecognised locale hour format';; + esac + + case $(LC_ALL="$loc" date -d '2025-10-11T01:00') in + *"$compare_time"*) ;; + *) fail=1 ;; + esac done