Update Sweden holidays: add legally-recognized non-public holidays as DE_FACTO category#3138
Conversation
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughAdds a new DE_FACTO holiday category and constant; updates Sweden to expose and populate de-facto holidays (Midsommarafton, Julafton, Nyårsafton); updates docs, tests, and localized message catalogs to reflect the new category and translations. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new DE_FACTO holiday category to fix incorrect working day calculations for Sweden, where certain holidays (Midsummer's Eve, Christmas Eve, and New Year's Eve) are legally required to be treated as non-working days per Swedish Annual Leave Law (SFS 1977:480), despite not being official public holidays.
Key changes:
- Added new
DE_FACTOconstant and category with legal backing for holidays treated equivalently to public holidays - Migrated three Swedish holidays from
BANKandOPTIONALcategories to the newDE_FACTOcategory - Updated documentation and locale files to support the new category
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| holidays/constants.py | Added DE_FACTO constant definition |
| holidays/countries/sweden.py | Added _populate_de_facto_holidays() method and moved three holidays to new category |
| tests/countries/test_sweden.py | Added comprehensive test coverage for DE_FACTO category and is_working_day() validation |
| docs/holiday_categories.md | Added documentation explaining the new DE_FACTO category with usage examples |
| holidays/locale/en_US/LC_MESSAGES/SE.po | Reorganized translations for the three migrated holidays |
| holidays/locale/sv/LC_MESSAGES/SE.po | Reorganized translations for the three migrated holidays |
| holidays/locale/th/LC_MESSAGES/SE.po | Reorganized translations for the three migrated holidays |
| holidays/locale/uk/LC_MESSAGES/SE.po | Reorganized translations for the three migrated holidays |
| README.md | Updated Sweden's supported categories to include DE_FACTO |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #3138 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 306 306
Lines 18167 18248 +81
Branches 2301 2327 +26
=========================================
+ Hits 18167 18248 +81 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
DE_FACTO category
- Include de facto holidays in bank holidays via _populate_de_facto_holidays() - Update tests to reflect de facto holidays in BANK category - Simplify comment in _populate_de_facto_holidays()
|
Made sure to populate the bank days with defacto too. Optional ones are not being populated with DE_FACTO yet. If we also were to populate optional then I would question why DE_FACTO is even necessary in the first place since they would always be added. |
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (4)
holidays/locale/sv/LC_MESSAGES/SE.po (1)
99-99: Duplicate: Comment formatting issue.Same issue as en_US file. Will be automatically fixed when
make l10nis run after correcting the en_US file.holidays/locale/th/LC_MESSAGES/SE.po (1)
99-99: Duplicate: Comment formatting issue.Same issue as en_US file. Will be automatically fixed when
make l10nis run after correcting the en_US file.tests/countries/test_sweden.py (1)
415-422: Remove test method docstring and reorder.Test methods in this project typically don't have docstrings. Also, consider moving this method after
test_bank_2022to group it with related category tests.Apply this diff:
- def test_de_facto_2022(self): - """Test all DE_FACTO holidays for 2022.""" + def test_de_facto_2022(self): self.assertHolidays(And consider moving the entire method to line 402 (right after
test_bank_2022).holidays/countries/sweden.py (1)
151-159: Fix comment formatting.Line 152 is missing a period, inconsistent with other comments in the file.
Apply this diff:
def _populate_de_facto_holidays(self): - # Midsummer Eve + # Midsummer Eve. self._add_holiday_1st_fri_from_jun_19(tr("Midsommarafton"))After making this change, run
make l10nto update all .po files with the corrected comment.
|
PPsyrius
left a comment
There was a problem hiding this comment.
LGTM 🇸🇪
Feel free to add your own name to CONTRIBUTORS as well 🎉
Signed-off-by: Viktor Rosvall <[email protected]>



Proposed change
This PR introduces a new
DE_FACTOholiday category to address issue #3118 whereis_working_day()incorrectly identified certain Swedish holidays as working days.According to Swedish Annual Leave Law (SFS 1977:480), Midsummer's Eve, Christmas Eve, and New Year's Eve must be treated equivalently to Sundays and public holidays for working day calculations, even though they are not official public holidays.
Changes
DE_FACTOconstant inholidays/constants.pyfor holidays that are legally treated like public holidays but are not officially designated as suchBANKandOPTIONALcategories to the newDE_FACTOcategory_populate_de_facto_holidays()method to handle these special holidaysDE_FACTOdocs/holiday_categories.mdexplaining the new category with usage examplesis_working_day()validationBreaking Change
This is a MINOR breaking change for Sweden holidays with the OPTIONAL category.
Previous behavior:
New behavior:
Impact:
Rationale:
These holidays are not optional holidays—they are legally mandated to be treated like public holidays for working day calculations per Swedish Annual Leave Law (SFS 1977:480). The Riksbank (Swedish central bank) also recognizes them as bank holidays.
Usage
For accurate working day calculations in Sweden, use:
Legal Reference
Per Swedish Annual Leave Law (SFS 1977:480, Section 7):
Source: https://www.riksdagen.se/sv/dokument-och-lagar/dokument/svensk-forfattningssamling/semesterlag-1977480_sfs-1977-480/
Fixes #3118
Type of change
holidaysfunctionality in general)Checklist
make checklocally; all checks and tests passed.