Skip to content

Commit

Permalink
Merge pull request #66 from TheChilliPL/master
Browse files Browse the repository at this point in the history
Fix Polish support
  • Loading branch information
goodsign committed Dec 20, 2023
2 parents 534cfb3 + 8554afa commit 4738e5b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
7 changes: 7 additions & 0 deletions default_formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ const (
DefaultFormatNbNODateTime = "15:04 02.01.06"
DefaultFormatNbNOTime = "15:04"

DefaultFormatPlPLFull = "Monday, 2 January 2006" // Polish (Poland)
DefaultFormatPlPLLong = "2 January 2006"
DefaultFormatPlPLMedium = "02 Jan 2006"
DefaultFormatPlPLShort = "02.01.2006"
DefaultFormatPlPLDateTime = "02.01.2006, 15:04"
DefaultFormatPlPLTime = "15:04"

DefaultFormatPtPTFull = "Monday, 2 de January de 2006" // Portuguese (Portugal)
DefaultFormatPtPTLong = "2 de January de 2006"
DefaultFormatPtPTMedium = "02/01/2006"
Expand Down
30 changes: 30 additions & 0 deletions format_pl_pl.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ var longMonthNamesPlPL = map[string]string{
"December": "Grudzień",
}

var longMonthNamesGenitivePlPL = map[string]string{
"January": "stycznia",
"February": "lutego",
"March": "marca",
"April": "kwietnia",
"May": "maja",
"June": "czerwca",
"July": "lipca",
"August": "sierpnia",
"September": "września",
"October": "października",
"November": "listopada",
"December": "grudnia",
}

var shortMonthNamesPlPL = map[string]string{
"Jan": "Sty",
"Feb": "Lut",
Expand All @@ -54,3 +69,18 @@ var shortMonthNamesPlPL = map[string]string{
"Nov": "Lis",
"Dec": "Gru",
}

var shortMonthNamesGenitivePlPL = map[string]string{
"Jan": "sty",
"Feb": "lut",
"Mar": "mar",
"Apr": "kwi",
"May": "maj",
"Jun": "cze",
"Jul": "lip",
"Aug": "sie",
"Sep": "wrz",
"Oct": "paź",
"Nov": "lis",
"Dec": "gru",
}
6 changes: 4 additions & 2 deletions monday.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var internalFormatFuncs = map[Locale]internalFormatFunc{
LocaleItIT: createCommonFormatFunc(LocaleItIT),
LocaleNnNO: createCommonFormatFunc(LocaleNnNO),
LocaleNbNO: createCommonFormatFunc(LocaleNbNO),
LocalePlPL: createCommonFormatFunc(LocalePlPL),
LocalePlPL: createCommonFormatFuncWithGenitive(LocalePlPL),
LocalePtPT: createCommonFormatFunc(LocalePtPT),
LocalePtBR: createCommonFormatFunc(LocalePtBR),
LocaleRoRO: createCommonFormatFunc(LocaleRoRO),
Expand Down Expand Up @@ -80,7 +80,7 @@ var internalParseFuncs = map[Locale]internalParseFunc{
LocaleItIT: createCommonParseFunc(LocaleItIT),
LocaleNnNO: createCommonParseFunc(LocaleNnNO),
LocaleNbNO: createCommonParseFunc(LocaleNbNO),
LocalePlPL: parseFuncPtCommon(LocalePlPL),
LocalePlPL: createCommonParseFuncWithGenitive(LocalePlPL),
LocalePtPT: parseFuncPtCommon(LocalePtPT),
LocalePtBR: parseFuncPtCommon(LocalePtBR),
LocaleRoRO: createCommonParseFunc(LocaleRoRO),
Expand Down Expand Up @@ -248,6 +248,8 @@ func fillKnownWords() {
fillKnownDaysShort(shortDayNamesPlPL, LocalePlPL)
fillKnownMonthsLong(longMonthNamesPlPL, LocalePlPL)
fillKnownMonthsShort(shortMonthNamesPlPL, LocalePlPL)
fillKnownMonthsGenitiveLong(longMonthNamesGenitivePlPL, LocalePlPL)
fillKnownMonthsGenitiveShort(shortMonthNamesGenitivePlPL, LocalePlPL)

// Pt_PT: Portuguese (Portugal)
fillKnownDaysLong(longDayNamesPtPT, LocalePtPT)
Expand Down
8 changes: 4 additions & 4 deletions monday_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ var formatTests = []FormatTest{
{LocalePlPL, time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC), "Mon Jan 2 2006", "Wto Wrz 3 2013"},
{LocalePlPL, time.Date(2013, 9, 4, 0, 0, 0, 0, time.UTC), "Monday Jan 2 2006", "Środa Wrz 4 2013"},
{LocalePlPL, time.Date(2013, 10, 3, 0, 0, 0, 0, time.UTC), "Monday January 02 2006", "Czwartek Październik 03 2013"},
{LocalePlPL, time.Date(2013, 11, 3, 0, 0, 0, 0, time.UTC), "Monday. 2 January 2006", "Niedziela. 3 Listopad 2013"},
{LocalePlPL, time.Date(2013, 5, 13, 0, 0, 0, 0, time.UTC), "2006. 2 January. Monday", "2013. 13 Maj. Poniedziałek"},
{LocalePlPL, time.Date(2013, 5, 13, 0, 0, 0, 0, time.UTC), "2 Jan 2006", "13 Maj 2013"},
{LocalePlPL, time.Date(2013, 11, 3, 0, 0, 0, 0, time.UTC), "Monday. 2 January 2006", "Niedziela. 3 listopada 2013"},
{LocalePlPL, time.Date(2013, 5, 13, 0, 0, 0, 0, time.UTC), "2006. 2 January. Monday", "2013. 13 maja. Poniedziałek"},
{LocalePlPL, time.Date(2013, 5, 13, 0, 0, 0, 0, time.UTC), "2 Jan 2006", "13 maj 2013"},
{LocalePlPL, time.Date(0, 5, 1, 0, 0, 0, 0, time.UTC), "January", "Maj"},
{LocalePlPL, time.Date(0, 5, 13, 0, 0, 0, 0, time.UTC), "2 January", "13 Maj"},
{LocalePlPL, time.Date(0, 5, 13, 0, 0, 0, 0, time.UTC), "2 January", "13 maja"},

{LocalePtPT, time.Date(2013, 9, 3, 0, 0, 0, 0, time.UTC), "Mon Jan 2 2006", "ter Set 3 2013"},
{LocalePtPT, time.Date(2013, 9, 4, 0, 0, 0, 0, time.UTC), "Monday Jan 2 2006", "Quarta-feira Set 4 2013"},
Expand Down

0 comments on commit 4738e5b

Please sign in to comment.