MCPcopy
hub / github.com/pocketbase/pocketbase / TestDateTimeUnix

Function TestDateTimeUnix

tools/types/datetime_test.go:256–279  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

254}
255
256func TestDateTimeUnix(t *testing.T) {
257 scenarios := []struct {
258 date string
259 expected int64
260 }{
261 {"", -62135596800},
262 {"2022-01-01 11:23:45.678Z", 1641036225},
263 }
264
265 for i, s := range scenarios {
266 t.Run(fmt.Sprintf("%d_%s", i, s.date), func(t *testing.T) {
267 dt, err := types.ParseDateTime(s.date)
268 if err != nil {
269 t.Fatal(err)
270 }
271
272 v := dt.Unix()
273
274 if v != s.expected {
275 t.Fatalf("Expected %d, got %d", s.expected, v)
276 }
277 })
278 }
279}
280
281func TestDateTimeIsZero(t *testing.T) {
282 dt0 := types.DateTime{}

Callers

nothing calls this directly

Calls 3

ParseDateTimeFunction · 0.92
UnixMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…