diff --git a/cmd/site/internal/date.go b/cmd/site/internal/date.go index cc81a1c..960cdc2 100644 --- a/cmd/site/internal/date.go +++ b/cmd/site/internal/date.go @@ -2,7 +2,7 @@ package internal import "time" -const iOS13DetriFormat = `2006 M01 2` +const iOS13DetriFormat = `2006 M1 2` // IOS13Detri formats a datestamp like iOS 13 does with the Lojban locale. func IOS13Detri(t time.Time) string { diff --git a/cmd/site/internal/date_test.go b/cmd/site/internal/date_test.go new file mode 100644 index 0000000..60254f9 --- /dev/null +++ b/cmd/site/internal/date_test.go @@ -0,0 +1,28 @@ +package internal + +import ( + "fmt" + "testing" + "time" +) + +func TestIOS13Detri(t *testing.T) { + cases := []struct { + in time.Time + out string + }{ + { + in: time.Date(2019, time.March, 30, 0, 0, 0, 0, time.FixedZone("UTC", 0)), + out: "2019 M3 30", + }, + } + + for _, cs := range cases { + t.Run(fmt.Sprintf("%s -> %s", cs.in.Format(time.RFC3339), cs.out), func(t *testing.T) { + result := IOS13Detri(cs.in) + if result != cs.out { + t.Fatalf("wanted: %s, got: %s", cs.out, result) + } + }) + } +}