MCPcopy
hub / github.com/expr-lang/expr / TestTime_date

Function TestTime_date

test/time/time_test.go:118–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestTime_date(t *testing.T) {
119 var tests = []struct {
120 input string
121 want time.Time
122 }{
123 {
124 `date('2017-10-23')`,
125 time.Date(2017, 10, 23, 0, 0, 0, 0, time.UTC),
126 },
127 {
128 `date('24.11.1987 20:30', "02.01.2006 15:04", "Europe/Zurich")`,
129 time.Date(1987, 11, 24, 20, 30, 0, 0, time.FixedZone("Europe/Zurich", 3600)),
130 },
131 {
132 `date('24.11.1987 20:30 MSK', "02.01.2006 15:04 MST", "Europe/Zurich")`,
133 time.Date(1987, 11, 24, 20, 30, 0, 0, time.FixedZone("MSK", 0)),
134 },
135 }
136 for _, test := range tests {
137 t.Run(test.input, func(t *testing.T) {
138 program, err := expr.Compile(test.input)
139 require.NoError(t, err)
140
141 output, err := expr.Run(program, nil)
142 require.NoError(t, err)
143 require.Truef(t, test.want.Equal(output.(time.Time)), "want %v, got %v", test.want, output)
144 })
145 }
146}

Callers

nothing calls this directly

Calls 6

CompileFunction · 0.92
NoErrorFunction · 0.92
RunFunction · 0.92
TruefFunction · 0.92
RunMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…