From 6cec0625acb2f307a166c31ab25fb599018d50d6 Mon Sep 17 00:00:00 2001 From: nishad shabbir Date: Sun, 9 Aug 2026 20:42:13 +0530 Subject: [PATCH] Fix misaligned Sinhala day abbreviations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `day_abbreviations` table for the Sinhala locale is shifted from Tuesday onward. Tuesday carries Wednesday's abbreviation, Thursday carries Friday's, Friday carries Saturday's, and Tuesday's own "අ" ends up in the Saturday slot. As a result Tuesday and Wednesday both render as "බදා", and Thursday has no abbreviation of its own at all. Each abbreviation should be a prefix of the day name it labels. That holds for Monday, Wednesday and Sunday, and fails for the other four, where the value is a prefix of a neighbouring day's name instead. Move the existing entries into their correct slots and add the missing Thursday abbreviation. `test_weekday` asserted that Saturday abbreviates to "අ", which is Tuesday's abbreviation. It was written from the table rather than from the language, so it locked the bug in; it now expects "සෙන". --- arrow/locales.py | 4 ++-- tests/test_locales.py | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/arrow/locales.py b/arrow/locales.py index 757df480d..b567d095f 100644 --- a/arrow/locales.py +++ b/arrow/locales.py @@ -6173,11 +6173,11 @@ def describe( day_abbreviations = [ "", "සදුද", + "අ", "බදා", - "බදා", + "බ්‍රහ", "සිකු", "සෙන", - "අ", "ඉරිදා", ] diff --git a/tests/test_locales.py b/tests/test_locales.py index 3d7120e36..a07adeae5 100644 --- a/tests/test_locales.py +++ b/tests/test_locales.py @@ -2951,7 +2951,26 @@ def test_format_relative_past(self): def test_weekday(self): dt = arrow.Arrow(2015, 4, 11, 17, 30, 00) assert self.locale.day_name(dt.isoweekday()) == "සෙනසුරාදා" - assert self.locale.day_abbreviation(dt.isoweekday()) == "අ" + assert self.locale.day_abbreviation(dt.isoweekday()) == "සෙන" + + def test_day_abbreviations(self): + # Each abbreviation must label the day it belongs to. Tuesday through + # Saturday used to be shifted by one, so Tuesday and Wednesday shared + # "බදා" and Thursday had no abbreviation of its own. + assert self.locale.day_abbreviation(1) == "සදුද" + assert self.locale.day_abbreviation(2) == "අ" + assert self.locale.day_abbreviation(3) == "බදා" + assert self.locale.day_abbreviation(4) == "බ්‍රහ" + assert self.locale.day_abbreviation(5) == "සිකු" + assert self.locale.day_abbreviation(6) == "සෙන" + assert self.locale.day_abbreviation(7) == "ඉරිදා" + + for day in range(1, 8): + assert self.locale.day_name(day).startswith( + self.locale.day_abbreviation(day) + ) + + assert len(set(self.locale.day_abbreviations[1:])) == 7 @pytest.mark.usefixtures("lang_locale")