Adding a country | holidays-rust | Spatie      

 SPATIE  

holidays-rust
=============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Holidays-rust](https://spatie.be/docs/holidays-rust/v1)  Adding a country

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/holidays-rust/v1) 

  Adding a country    
- [ Introduction ](https://spatie.be/docs/holidays-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/holidays-rust/v1/support-us)
- [ Installation ](https://spatie.be/docs/holidays-rust/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/holidays-rust/v1/usage)
- [ Coverage and compatibility ](https://spatie.be/docs/holidays-rust/v1/compatibility)
- [ Adding a country ](https://spatie.be/docs/holidays-rust/v1/adding-a-country)
- [ Testing ](https://spatie.be/docs/holidays-rust/v1/testing)
- [ Changelog ](https://spatie.be/docs/holidays-rust/v1/changelog)

 Adding a country
================

###  On this page 

1. [ Basic country ](#content-basic-country)
2. [ Register your country ](#content-register-your-country)
3. [ Regional holidays ](#content-regional-holidays)
4. [ Observed holidays ](#content-observed-holidays)
5. [ Holiday types ](#content-holiday-types)
6. [ Translations ](#content-translations)
7. [ Testing ](#content-testing)

This is a community driven package. If you find any errors, please create a pull request with the fix, or at least open an issue.

Basic country
-----------------------------------------------------------------------------------------------

Add a module under `src/countries`. Follow a neighboring country's rules, using the shared date, Easter and observed-day calculations. Return `Holiday` values with the original names, classifications and region codes. Keep date rules as calculations; do not replace a rule with a list of dates calculated for a few selected years.

```
let holiday = Holiday {
    name: "New Year's Day".into(),
    date: Date::from_ymd_opt(year, 1, 1).unwrap(),
    holiday_type: HolidayType::National,
    region: None,
};
```

The internal `calendar` module owns Easter, Orthodox Easter, relative weekdays, multi-day periods and substitute-day helpers. The `chinese` module contains the astronomical Chinese calendar calculation. Islamic civil conversion uses the tabular Islamic calendar. Some holidays depend on official announcements; retain those dated source records and reject years where the required data is unavailable.

Register your country
-----------------------------------------------------------------------------------------------------------------------

Add the ISO country code to `COUNTRIES` in `src/countries/mod.rs` and add its calculation branch. Keep aliases separate from the country's canonical code. Unknown codes must still return `Error::InvalidCountry`.

Regional holidays
-----------------------------------------------------------------------------------------------------------

Add accepted region codes to the same registry's `regions` function. Keep exact spelling and case. Specify whether selecting no region returns national holidays only or combines regional calendars; existing countries differ. Attach the applicable region to regional `Holiday` values, without inferring it from the active query when the rule specifies another value.

Observed holidays
-----------------------------------------------------------------------------------------------------------

Use the existing observed-day helpers where the legal rule agrees with them. A Saturday, a Sunday and a collision with another holiday can require different substitutions. Include all of these in tests rather than checking only a year with weekday holidays.

Holiday types
-----------------------------------------------------------------------------------------------

The types are `National`, `Regional`, `Observed`, `Religious` and `Bank`. Preserve the source's classification. Do not turn every religious date into a public holiday without checking the country's calendar.

Translations
--------------------------------------------------------------------------------------------

Translations are in `src/translations.json`, grouped by canonical country code and locale. Use the original holiday name as the key. Missing translations keep the original name. Update the default-locale selection only when that is the country's documented behavior.

Testing
-----------------------------------------------------------------------------

Add public API cases for the rule's boundaries. If porting a PHP calendar, regenerate the independent [differential fixtures](testing) against the pinned upstream revision and inspect every changed result. A new rule needs an official source and a test that distinguishes it from the previous rule. Run the quality checks on both stable Rust and the minimum supported version.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
