ParseDate should handle DateFormat

This commit is contained in:
Dan Jones 2024-02-25 12:36:43 -06:00
commit 391452e3d9
6 changed files with 17 additions and 940 deletions

View file

@ -23,9 +23,11 @@ func TestParseDate(t *testing.T) {
firstMonth := time.Date(y, mon, 1, 0, 0, 0, 0, loc)
firstYear := time.Date(y, 1, 1, 0, 0, 0, 0, loc)
exact := "2075-02-12T12:13:54.536-02:00"
exactd, _ := time.ParseInLocation(time.RFC3339, exact, time.FixedZone("UTC-02:00", -2*60*60))
exactd, _ := time.ParseInLocation(time.RFC3339, exact, time.FixedZone("UTC-02:00", -7200))
var ts int64 = 1708876012
tsd := time.Unix(ts, 0)
ent := "February 25, 2024 at 04:00:13AM +0230"
entd, _ := time.Parse(DateFormat, ent)
tests := []struct {
name string
@ -44,6 +46,7 @@ func TestParseDate(t *testing.T) {
{"max", MaxTime, ""},
{exact, exactd, ""},
{fmt.Sprint(ts), tsd, ""},
{ent, entd, ""},
{"not a date", now, fmt.Sprintf(`failed to parse "%s": unknown format`, "not a date")},
}
for _, tt := range tests {