diff --git a/default_formats.go b/default_formats.go index b874096..be7929f 100644 --- a/default_formats.go +++ b/default_formats.go @@ -263,6 +263,13 @@ const ( DefaultFormatThTHShort = "02/01/2006" DefaultFormatThTHDateTime = "02/01/2006 15:04" DefaultFormatThTHTime = "15:04" + + DefaultFormatUzUZFull = "Monday, 02 January 2006" // Uzbek (Uzbekistan) + DefaultFormatUzUZLong = "2 January 2006" + DefaultFormatUzUZMedium = "2 Jan 2006" + DefaultFormatUzUZShort = "02.01.2006" + DefaultFormatUzUZDateTime = "02.01.2006 15:04" + DefaultFormatUzUZTime = "15:04" ) // FullFormatsByLocale maps locales to the'full' date formats for all @@ -305,6 +312,7 @@ var FullFormatsByLocale = map[Locale]string{ LocaleUkUA: DefaultFormatUkUAFull, LocaleLtLT: DefaultFormatLtLTFull, LocaleThTH: DefaultFormatThTHFull, + LocaleUzUZ: DefaultFormatUzUZFull, } // LongFormatsByLocale maps locales to the 'long' date formats for all @@ -347,6 +355,7 @@ var LongFormatsByLocale = map[Locale]string{ LocaleUkUA: DefaultFormatUkUALong, LocaleLtLT: DefaultFormatLtLTLong, LocaleThTH: DefaultFormatThTHLong, + LocaleUzUZ: DefaultFormatUzUZLong, } // MediumFormatsByLocale maps locales to the 'medium' date formats for all @@ -389,6 +398,7 @@ var MediumFormatsByLocale = map[Locale]string{ LocaleUkUA: DefaultFormatUkUAMedium, LocaleLtLT: DefaultFormatLtLTMedium, LocaleThTH: DefaultFormatThTHMedium, + LocaleUzUZ: DefaultFormatUzUZMedium, } // ShortFormatsByLocale maps locales to the 'short' date formats for all @@ -430,7 +440,7 @@ var ShortFormatsByLocale = map[Locale]string{ LocaleCsCZ: DefaultFormatCsCZShort, LocaleUkUA: DefaultFormatUkUAShort, LocaleLtLT: DefaultFormatLtLTShort, - LocaleThTH: DefaultFormatThTHShort, + LocaleUzUZ: DefaultFormatUzUZShort, } // DateTimeFormatsByLocale maps locales to the 'DateTime' date formats for @@ -472,7 +482,7 @@ var DateTimeFormatsByLocale = map[Locale]string{ LocaleCsCZ: DefaultFormatCsCZDateTime, LocaleUkUA: DefaultFormatUkUADateTime, LocaleLtLT: DefaultFormatLtLTDateTime, - LocaleThTH: DefaultFormatThTHDateTime, + LocaleUzUZ: DefaultFormatUzUZDateTime, } // TimeFormatsByLocale maps locales to the 'Time' date formats for @@ -514,5 +524,5 @@ var TimeFormatsByLocale = map[Locale]string{ LocaleCsCZ: DefaultFormatCsCZTime, LocaleUkUA: DefaultFormatUkUATime, LocaleLtLT: DefaultFormatLtLTTime, - LocaleThTH: DefaultFormatThTHTime, + LocaleUzUZ: DefaultFormatUzUZTime, } diff --git a/format_uz_uz.go b/format_uz_uz.go new file mode 100644 index 0000000..0f750c3 --- /dev/null +++ b/format_uz_uz.go @@ -0,0 +1,85 @@ +package monday + +// ============================================================ +// Format rules for "uz_UZ" locale: Uzbek (Uzbeksitan) +// ============================================================ + +var longDayNamesUzUZ = map[string]string{ + "Sunday": "Yakshanba", + "Monday": "Dushanba", + "Tuesday": "Seshanba", + "Wednesday": "Chorshanba", + "Thursday": "Payshanba", + "Friday": "Juma", + "Saturday": "Shanba", +} + +var shortDayNamesUzUZ = map[string]string{ + "Sun": "Ya", + "Mon": "Du", + "Tue": "Se", + "Wed": "Ch", + "Thu": "Pa", + "Fri": "Ju", + "Sat": "Sh", +} + +var longMonthNamesUzUZ = map[string]string{ + "January": "Yanvar", + "February": "Fevral", + "March": "Mart", + "April": "Aprel", + "May": "May", + "June": "Iyun", + "July": "Iyul", + "August": "Avgust", + "September": "Sentyabr", + "October": "Oktyabr", + "November": "Noyabr", + "December": "Dekabr", +} + +var longMonthNamesGenitiveUzUZ = map[string]string{ + "January": "yanvar", + "February": "fevral", + "March": "mart", + "April": "aprel", + "May": "may", + "June": "iyun", + "July": "iyul", + "August": "avgust", + "September": "sentyabr", + "October": "oktyabr", + "November": "noyabr", + "December": "dekabr", +} + +var shortMonthNamesUzUZ = map[string]string{ + "Jan": "Yan", + "Feb": "Fev", + "Mar": "Mar", + "Apr": "Apr", + "May": "May", + "Jun": "Iyun", + "Jul": "Iyul", + "Aug": "Avg", + "Sep": "Sen", + "Oct": "Okt", + "Nov": "Noy", + "Dec": "Dek", +} + +var shortMonthNamesGenitiveUzUZ = map[string]string{ + "Jan": "yan", + "Feb": "fev", + "Mar": "mar", + "Apr": "apr", + "May": "may", + "Jun": "iyun", + "Jul": "iyul", + "Aug": "avg", + "Sep": "sen", + "Oct": "okt", + "Nov": "noy", + "Dec": "dek", +} diff --git a/locale.go b/locale.go index 6df2e97..44ec74c 100644 --- a/locale.go +++ b/locale.go @@ -47,6 +47,7 @@ const ( LocaleSlSI = "sl_SI" // Slovenian (Slovenia) LocaleLtLT = "lt_LT" // Lithuanian (Lithuania) LocaleThTH = "th_TH" // Thai (Thailand) + LocaleUzUZ = "uz_UZ" // Uzbek (Uzbekistan) ) // ListLocales returns all locales supported by the package. @@ -91,5 +92,6 @@ func ListLocales() []Locale { LocaleSlSI, LocaleLtLT, LocaleThTH, + LocaleUzUZ, } } diff --git a/monday.go b/monday.go index e12783d..8c03061 100644 --- a/monday.go +++ b/monday.go @@ -49,6 +49,7 @@ var internalFormatFuncs = map[Locale]internalFormatFunc{ LocaleSlSI: createCommonFormatFunc(LocaleSlSI), LocaleLtLT: createCommonFormatFuncWithGenitive(LocaleLtLT), LocaleThTH: createCommonFormatFunc(LocaleThTH), + LocaleUzUZ: createCommonFormatFuncWithGenitive(LocaleUzUZ), } // internalParseFunc is a preprocessor for default time.ParseInLocation func @@ -95,6 +96,7 @@ var internalParseFuncs = map[Locale]internalParseFunc{ LocaleSlSI: createCommonParseFunc(LocaleSlSI), LocaleLtLT: createCommonParsetFuncWithGenitive(LocaleLtLT), LocaleThTH: parseFuncThCommon(LocaleThTH), + LocaleUzUZ: createCommonParsetFuncWithGenitive(LocaleUzUZ), } var knownDaysShort = map[Locale]map[string]string{} // Mapping for 'Format', days of week, short form @@ -373,6 +375,14 @@ func fillKnownWords() { fillKnownDaysShort(shortDayNamesThTH, LocaleThTH) fillKnownMonthsLong(longMonthNamesThTH, LocaleThTH) fillKnownMonthsShort(shortMonthNamesThTH, LocaleThTH) + + // Uz_UZ: Uzbek (Uzbekistan) + fillKnownDaysLong(longDayNamesUzUZ, LocaleUzUZ) + fillKnownDaysShort(shortDayNamesUzUZ, LocaleUzUZ) + fillKnownMonthsLong(longMonthNamesUzUZ, LocaleUzUZ) + fillKnownMonthsShort(shortMonthNamesUzUZ, LocaleUzUZ) + fillKnownMonthsGenitiveLong(longMonthNamesGenitiveUzUZ, LocaleUzUZ) + fillKnownMonthsGenitiveShort(shortMonthNamesGenitiveUzUZ, LocaleUzUZ) } func fill(src map[string]string, dest map[Locale]map[string]string, locale Locale) { diff --git a/monday_test.go b/monday_test.go index cc7de78..09c296d 100644 --- a/monday_test.go +++ b/monday_test.go @@ -360,6 +360,15 @@ var formatTests = []FormatTest{ {LocaleThTH, time.Date(2022, 5, 13, 0, 0, 0, 0, time.UTC), "2 Jan 2006", "13 พ.ค. 2022"}, {LocaleThTH, time.Date(0, 5, 1, 0, 0, 0, 0, time.UTC), "January", "พฤษภาคม"}, {LocaleThTH, time.Date(0, 5, 13, 0, 0, 0, 0, time.UTC), "2 January", "13 พฤษภาคม"}, + + {LocaleUzUZ, time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC), "Mon Jan 2 2006", "Se Sen 3 2013"}, + {LocaleUzUZ, time.Date(2013, 9, 4, 0, 0, 0, 0, time.UTC), "Monday Jan 2 2006", "Chorshanba Sen 4 2013"}, + {LocaleUzUZ, time.Date(2013, 10, 3, 0, 0, 0, 0, time.UTC), "Monday January 02 2006", "Payshanba Oktyabr 03 2013"}, + {LocaleUzUZ, time.Date(2013, 11, 3, 0, 0, 0, 0, time.UTC), "Monday. 2 January 2006", "Yakshanba. 3 noyabr 2013"}, + {LocaleUzUZ, time.Date(2013, 5, 13, 0, 0, 0, 0, time.UTC), "2006. 2 January. Monday", "2013. 13 may. Dushanba"}, + {LocaleUzUZ, time.Date(2013, 5, 13, 0, 0, 0, 0, time.UTC), "2 Jan 2006", "13 may 2013"}, + {LocaleUzUZ, time.Date(0, 5, 1, 0, 0, 0, 0, time.UTC), "January", "May"}, + {LocaleUzUZ, time.Date(0, 5, 13, 0, 0, 0, 0, time.UTC), "2 January", "13 may"}, } func TestFormat(t *testing.T) {