internal: test date
This commit is contained in:
parent
f3a411a620
commit
bf56cf56fa
|
@ -2,7 +2,7 @@ package internal
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
const iOS13DetriFormat = `2006 M01 2`
|
const iOS13DetriFormat = `2006 M1 2`
|
||||||
|
|
||||||
// IOS13Detri formats a datestamp like iOS 13 does with the Lojban locale.
|
// IOS13Detri formats a datestamp like iOS 13 does with the Lojban locale.
|
||||||
func IOS13Detri(t time.Time) string {
|
func IOS13Detri(t time.Time) string {
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue