Skip to content

Fix misaligned Sinhala day abbreviations - #1336

Open
Nishuuzz wants to merge 1 commit into
arrow-py:masterfrom
Nishuuzz:fix-sinhala-day-abbreviations
Open

Fix misaligned Sinhala day abbreviations#1336
Nishuuzz wants to merge 1 commit into
arrow-py:masterfrom
Nishuuzz:fix-sinhala-day-abbreviations

Conversation

@Nishuuzz

@Nishuuzz Nishuuzz commented Aug 9, 2026

Copy link
Copy Markdown

The weekday abbreviations in the Sinhala locale don't line up with the days they belong to. From Tuesday onwards they're off by a slot: Tuesday holds Wednesday's abbreviation, Thursday holds Friday's, Friday holds Saturday's, and Tuesday's own one has ended up down in the Saturday slot.

Two things go wrong because of it. Tuesday and Wednesday both come out as බදා, so you can't tell them apart, and Thursday's abbreviation is missing from the table altogether:

>>> import arrow
>>> monday = arrow.Arrow(2026, 3, 9)
>>> [monday.shift(days=i).format("ddd", locale="si") for i in range(7)]
['සදුද', 'බදා', 'බදා', 'සිකු', 'සෙන', 'අ', 'ඉරිදා']

You don't have to read Sinhala to see that's wrong. Each abbreviation is meant to be the beginning of the day name it stands for, which is true for Monday, Wednesday and Sunday, but for Tuesday, Thursday, Friday and Saturday it's the beginning of a different day's name instead.

The fix is mostly just putting the existing entries back with the right days. Thursday was the one that had nothing to move back, so I've added බ්‍රහ, taken from the front of බ්‍රහස්‍පතින්‍දා the same way the others are formed from their day names.

I don't speak Sinhala, so I'd rather be clear about which bit is which. The reordering is mechanical and you can check it against the day names without knowing the language. The Thursday abbreviation is the one real judgement call, and if that isn't how it's normally shortened, tell me and I'll change it.

I also had to update test_weekday. It expected Saturday to abbreviate to , which is actually Tuesday's, so it was written to match the table rather than the language. That's presumably how this survived since the locale was added in #1044. The new test_day_abbreviations pins all seven, checks each one really is the start of its own day name, and checks they're all distinct.

Both tests fail before this change and pass after it. Full suite is green at 1902 passed, and black and flake8 are happy with both files.

One last thing while I was in here: Latvian uses pi for both pirmdiena and piektdiena, and Maltese uses Ħ for both Il-Ħamis and Il-Ħadd. Those are ambiguous rather than out of order, and choosing the right short forms needs someone who speaks the language, so I've left them alone. Happy to open an issue for them if it's worth tracking.

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 "සෙන".
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2224255) to head (6cec062).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1336   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         2315      2315           
  Branches       358       358           
=========================================
  Hits          2315      2315           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@Nishuuzz

Copy link
Copy Markdown
Author

any update?

@Mukller Mukller left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally on the PR branch (Python 3.13): pytest tests/test_locales.py -k "SinhalaLocale"7/7 green, including the new per-day abbreviation assertions.

The index-shift diagnosis is correct and the new mapping is linguistically consistent with the full day names:

isoweekday day_name old abbr new abbr
1 Monday සෙනසුරාදා-row සදුද සදුද
2 Tuesday (missing)
3 Wednesday බදා බදා
4 Thursday බදා (duplicate!) බ්‍රහ
5 Friday සිකු සිකු
6 Saturday සෙන සෙන
7 Sunday ඉරිදා ඉරිදා

Old table had Tuesday and Thursday sharing "බදා" while Tuesday's own "අ" sat in the Sunday slot and Saturday's "සෙන" was duplicated into the weekend — i.e. everything from Tuesday onward was shifted by one. The new table aligns each abbreviation with its full name (අඟහරුවාදා→අ, බදාදා→බදා, බ්‍රහස්පතින්දා→බ්‍රහ), and the updated test_weekday assertion (Saturday → "සෙන", not "අ") pins the correction.

Note this intentionally changes output for Tue–Thu; any consumer hard-coding the old (wrong) abbreviations will see different strings — that's the point of the fix, but worth a changelog line as a behavior change.

@Nishuuzz

Copy link
Copy Markdown
Author

Thanks for looking. The conclusion matches what I found, but a few rows don't match what's actually in master, so I'll correct them for anyone reading later.

Before this change: Monday සදුද, Tuesday බදා, Wednesday බදා, Thursday සිකු, Friday සෙන, Saturday අ, Sunday ඉරිදා. Tuesday wasn't missing an abbreviation, it had Wednesday's. Thursday had Friday's rather than a second බදා. And Tuesday's own අ was in the Saturday slot, not the Sunday one — Sunday was correct all along.

So the output changes for Tuesday, Thursday, Friday and Saturday, not Tuesday through Thursday. Wednesday keeps බදා.

On the changelog, CHANGELOG.rst looks like something the maintainers write when cutting a release, and recent behaviour fixes like #1242 didn't touch it, so I've left it alone. Happy to add a line if a maintainer wants one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants