Skip to content

Commit

Permalink
support additional date format
Browse files Browse the repository at this point in the history
  • Loading branch information
jakopako committed Dec 1, 2024
1 parent 25e07d9 commit 9a14888
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion date/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func GetDateFormat(date string, parts CoveredDateParts) (string, string) {
return defaultFormat, defaultLanguage
}

separators := []rune{' ', ',', '.', '-', ':', '@'}
separators := []rune{' ', ',', '.', '-', ':', '@', '/'}

tokens := []string{}
sepTokens := []string{}
Expand Down
32 changes: 32 additions & 0 deletions date/date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,35 @@ func TestGetDateFormat17(t *testing.T) {
}
}
}

func TestGetDateFormat18(t *testing.T) {
dateFormats := []formatTestStruct{
{
input: "Mi. 04/12/2024",
coveredParts: CoveredDateParts{Day: true, Month: true, Year: true},
formatString: "Mon. 2/1/2006",
language: "de_DE",
},
{
input: "Sa. 07/12/2024",
coveredParts: CoveredDateParts{Day: true, Month: true, Year: true},
formatString: "Mon. 2/1/2006",
language: "de_DE",
},
{
input: "Sa. 18/01/2024",
coveredParts: CoveredDateParts{Day: true, Month: true, Year: true},
formatString: "Mon. 2/1/2006",
language: "de_DE",
},
}
for _, df := range dateFormats {
f, l := GetDateFormat(df.input, df.coveredParts)
if f != df.formatString {
log.Fatalf("expected %s but got %s", df.formatString, f)
}
if l != df.language {
log.Fatalf("expected date language %s but got %s", df.language, l)
}
}
}

0 comments on commit 9a14888

Please sign in to comment.