Hi,

I've attached a basic test I wrote for the Thai solar calendar using
th_TH.UTF-8 based on the properties that Bruno described [1].

One thing I was unsure of was whether we have to check if the locale is
supported before using it. In other tests I see something like this:

    export LC_ALL=en_US.UTF-8
    if test "$(locale charmap 2>/dev/null)" = UTF-8; then
      # tests here
    fi

I could do that here if that is correct. But how would it be written for
"LC_ALL=fa_IR" and "LC_ALL=am_ET" which have no charset specified?

I'll hold off on writing the others until I get input on that. They
shouldn't be too difficult.

Collin

[1] https://lists.gnu.org/archive/html/bug-gnulib/2025-07/msg00102.html

>From 75389decab580d913abac8ead9b257bfbf4d959e Mon Sep 17 00:00:00 2001
Message-ID: <75389decab580d913abac8ead9b257bfbf4d959e.1752807269.git.collin.fu...@gmail.com>
From: Collin Funk <collin.fu...@gmail.com>
Date: Thu, 17 Jul 2025 19:42:30 -0700
Subject: [PATCH] date: add tests for the Thai solar calendar

* tests/date/date-thailand.sh: New file.
* tests/local.mk (all_tests): Add test.
---
 tests/date/date-thailand.sh | 36 ++++++++++++++++++++++++++++++++++++
 tests/local.mk              |  1 +
 2 files changed, 37 insertions(+)
 create mode 100755 tests/date/date-thailand.sh

diff --git a/tests/date/date-thailand.sh b/tests/date/date-thailand.sh
new file mode 100755
index 000000000..253440689
--- /dev/null
+++ b/tests/date/date-thailand.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Verify the Thai solar calendar is used with the Thai 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=th_TH.UTF-8
+
+# Since 1941, the year in the Thai solar calendar is the Gregorian year plus
+# 543.
+test $(date +%Y) == $(($current_year + 543)) || fail=1
+
+# All months that have 31 days end have names that end with "คม".
+for month in 01 03 05 07 08 10 12; do
+  date --date=$current_year-$month-01 +%B | grep คม$ || fail=1
+done
+
+Exit $fail
diff --git a/tests/local.mk b/tests/local.mk
index dd07032da..4cd1a34d2 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -310,6 +310,7 @@ all_tests =					\
   tests/csplit/csplit-suppress-matched.pl	\
   tests/date/date-debug.sh			\
   tests/date/date-sec.sh			\
+  tests/date/date-thailand.sh			\
   tests/date/date-tz.sh				\
   tests/misc/dircolors.pl			\
   tests/misc/dirname.pl				\
-- 
2.50.1

Reply via email to