Add support for first day of the week based on territory

This commit is contained in:
Greg Burri 2025-04-19 13:53:09 +02:00
parent 475024a97b
commit c8dd82a5e0

View file

@ -210,9 +210,56 @@ impl Tr {
// Return the first day of the week for the current language.
// See https://en.wikipedia.org/wiki/Week#First_day_of_the_week.
pub fn first_day_of_week(&self) -> Weekday {
match (self.lang.code.as_ref(), self.lang.territory.as_ref()) {
// TODO: Add more languages: https://en.wikipedia.org/wiki/Week.
("en", "US") => Weekday::Sun,
match self.lang.territory.as_ref() {
"US" // United States.
| "AR" // Argentina.
| "BZ" // Belize.
| "BO" // Bolivia.
| "BR" // Brazil.
| "CA" // Canada.
| "CL" // Chile.
| "CN" // China.
| "CO" // Colombia.
| "CR" // Costa Rica.
| "DO" // Dominican Republic.
| "EC" // Ecuador.
| "SV" // El Salvador.
| "GT" // Guatemala.
| "HN" // Honduras.
| "HK" // Hong Kong.
| "IL" // Israel.
| "JM" // Jamaica.
| "JP" // Japan.
| "KE" // Kenya.
| "MO" // Macao.
| "MX" // Mexico.
| "NI" // Nicaragua.
| "PA" // Panama.
| "PE" // Peru.
| "PH" // Philippines.
| "PR" // Puerto Rico.
| "ZA" // South Africa.
| "KR" // South Korea.
| "TW" // Taiwan.
| "VE" // Venezuela.
| "ZW" // Zimbabwe.
=> Weekday::Sun,
"AF" // Afghanistan.
| "DZ" // Algeria.
| "BH" // Bahrain.
| "EG" // Egypt.
| "IR" // Iran.
| "IQ" // Iraq.
| "JO" // Jordan.
| "KW" // Kuwait.
| "LY" // Libya.
| "OM" // Oman.
| "QA" // Qatar.
| "SA" // Saudi Arabia.
| "SY" // Syria.
| "AE" // United Arab Emirates.
| "YE" // Yemen.
=> Weekday::Sat,
_ => Weekday::Mon,
}
}