From c8dd82a5e082b88c7093423eb2bfabebfde6ec4f Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sat, 19 Apr 2025 13:53:09 +0200 Subject: [PATCH] Add support for first day of the week based on territory --- backend/src/translation.rs | 53 +++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/backend/src/translation.rs b/backend/src/translation.rs index ce7c6ba..6bced76 100644 --- a/backend/src/translation.rs +++ b/backend/src/translation.rs @@ -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, } }