1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package integration
import (
"testing"
"time"
_ "time/tzdata"
)
func TestTime(t *testing.T) {
f := `Mon Jan 02 15:04:05 MST 2006`
i := `Fri Feb 13 23:31:30 UTC 2009`
inOutTest(t, `{{ (time.Parse "`+f+`" "`+i+`").Format "2006-01-02 15 -0700" }}`,
"2009-02-13 23 +0000")
if !isWindows {
o, e, err := cmd(t, "-i", `{{ time.ZoneName }}`).withEnv("TZ", "UTC").run()
assertSuccess(t, o, e, err, "UTC")
o, e, err = cmd(t, "-i", `{{ time.ZoneOffset }}`).withEnv("TZ", "UTC").run()
assertSuccess(t, o, e, err, "0")
o, e, err = cmd(t, "-i",
`{{ (time.ParseLocal time.Kitchen "6:00AM").Format "15:04 MST" }}`).
withEnv("TZ", "Africa/Luanda").run()
assertSuccess(t, o, e, err, "06:00 LMT")
}
zname, _ := time.Now().Zone()
inOutTest(t, `{{ time.ZoneName }}`, zname)
inOutTest(t, `{{ (time.Now).Format "2006-01-02 15 -0700" }}`,
time.Now().Format("2006-01-02 15 -0700"))
inOutTest(t, `{{ (time.ParseInLocation time.Kitchen "Africa/Luanda" "6:00AM").Format "15:04 MST" }}`,
"06:00 LMT")
inOutTest(t, `{{ (time.Unix 1234567890).UTC.Format "2006-01-02 15 -0700" }}`,
"2009-02-13 23 +0000")
inOutTest(t, `{{ (time.Unix "1234567890").UTC.Format "2006-01-02 15 -0700" }}`,
"2009-02-13 23 +0000")
}
|