Collin Funk <collin.fu...@gmail.com> writes: >> thanks for working on this > > No problem, thanks to you and Berny for checking. I'll write tests for > the other two locales tomorrow.
Done, two patches attached. I'll push them tomorrow unless there is any issues. I ran 'make syntax-check' this time, so hopefully not. :) Collin
>From 1dde2777ae69c7533bca2e3d322b163de15840d3 Mon Sep 17 00:00:00 2001 Message-ID: <1dde2777ae69c7533bca2e3d322b163de15840d3.1753243018.git.collin.fu...@gmail.com> From: Collin Funk <collin.fu...@gmail.com> Date: Tue, 22 Jul 2025 20:14:35 -0700 Subject: [PATCH 1/2] tests: date: add tests for the Solar Hijri calendar * tests/date/date-iran.sh: New file. * tests/local.mk (all_tests): Add the test. --- tests/date/date-iran.sh | 45 +++++++++++++++++++++++++++++++++++++++++ tests/local.mk | 1 + 2 files changed, 46 insertions(+) create mode 100755 tests/date/date-iran.sh diff --git a/tests/date/date-iran.sh b/tests/date/date-iran.sh new file mode 100755 index 000000000..7c2d16be5 --- /dev/null +++ b/tests/date/date-iran.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Verify the Solar Hijri calendar is used in the Iranian locale. + +# Copyright (C) 2025 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ date + +# Current year in the Gregorian calendar. +current_year=$(LC_ALL=C date +%Y) + +export LC_ALL=fa_IR.UTF-8 + +if test "$(locale charmap 2>/dev/null)" != UTF-8; then + skip_ "Iranian UTF-8 locale not available" +fi + +# 03-19 and 03-22 of the same Gregorian year are in different years in the +# Solar Hijri calendar. +year_march_19=$(date -d $current_year-03-19 +%Y) +year_march_22=$(date -d $current_year-03-22 +%Y) +test $year_march_19 = $(($year_march_22 - 1)) || fail=1 + +# The difference between the Gregorian year is 621 or 622 years. +test $year_march_19 = $(($current_year - 622)) || fail=1 +test $year_march_22 = $(($current_year - 621)) || fail=1 + +# Check that --iso-8601 and --rfc-3339 uses the Gregorian calendar. +case $(date --iso-8601=hours) in $current_year-*) ;; *) fail=1 ;; esac +case $(date --rfc-3339=date) in $current_year-*) ;; *) fail=1 ;; esac + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk index 4cd1a34d2..16267a03f 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -309,6 +309,7 @@ all_tests = \ tests/csplit/csplit-io-err.sh \ tests/csplit/csplit-suppress-matched.pl \ tests/date/date-debug.sh \ + tests/date/date-iran.sh \ tests/date/date-sec.sh \ tests/date/date-thailand.sh \ tests/date/date-tz.sh \ -- 2.50.1
>From b66013f5186ee2aaf65f30df6c83e030cf8a8cfc Mon Sep 17 00:00:00 2001 Message-ID: <b66013f5186ee2aaf65f30df6c83e030cf8a8cfc.1753243018.git.collin.fu...@gmail.com> In-Reply-To: <1dde2777ae69c7533bca2e3d322b163de15840d3.1753243018.git.collin.fu...@gmail.com> References: <1dde2777ae69c7533bca2e3d322b163de15840d3.1753243018.git.collin.fu...@gmail.com> From: Collin Funk <collin.fu...@gmail.com> Date: Tue, 22 Jul 2025 20:30:49 -0700 Subject: [PATCH 2/2] tests: date: add tests for the Ethiopian calendar * tests/date/date-ethiopia.sh: New file. * tests/local.mk (all_tests): Add the test. --- tests/date/date-ethiopia.sh | 45 +++++++++++++++++++++++++++++++++++++ tests/local.mk | 1 + 2 files changed, 46 insertions(+) create mode 100755 tests/date/date-ethiopia.sh diff --git a/tests/date/date-ethiopia.sh b/tests/date/date-ethiopia.sh new file mode 100755 index 000000000..eda9a5a63 --- /dev/null +++ b/tests/date/date-ethiopia.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Verify the Ethiopian calendar is used in the Ethiopian locale. + +# Copyright (C) 2025 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ date + +# Current year in the Gregorian calendar. +current_year=$(LC_ALL=C date +%Y) + +export LC_ALL=am_ET.UTF-8 + +if test "$(locale charmap 2>/dev/null)" != UTF-8; then + skip_ "Ethiopian UTF-8 locale not available" +fi + +# 09-10 and 09-12 of the same Gregorian year are in different years in the +# Ethiopian calendar. +year_september_10=$(date -d $current_year-09-10 +%Y) +year_september_12=$(date -d $current_year-09-12 +%Y) +test $year_september_10 = $(($year_september_12 - 1)) || fail=1 + +# The difference between the Gregorian year is 7 or 8 years. +test $year_september_10 = $(($current_year - 8)) || fail=1 +test $year_september_12 = $(($current_year - 7)) || fail=1 + +# Check that --iso-8601 and --rfc-3339 uses the Gregorian calendar. +case $(date --iso-8601=hours) in $current_year-*) ;; *) fail=1 ;; esac +case $(date --rfc-3339=date) in $current_year-*) ;; *) fail=1 ;; esac + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk index 16267a03f..6b527f108 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -309,6 +309,7 @@ all_tests = \ tests/csplit/csplit-io-err.sh \ tests/csplit/csplit-suppress-matched.pl \ tests/date/date-debug.sh \ + tests/date/date-ethiopia.sh \ tests/date/date-iran.sh \ tests/date/date-sec.sh \ tests/date/date-thailand.sh \ -- 2.50.1