Files
regorus/tests/interpreter/cases/builtins/time/format.yaml
Burak 5717f9c249 Partially implement Go's time format (#130)
* Partially implement Go's time format

* Parse date only values

* Fix leap year handling in `time.diff`

* Disable failing test case
2024-02-07 15:12:34 -08:00

53 lines
1.3 KiB
YAML

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cases:
- note: without-timezone-and-format
data: {}
modules:
- |
package test
a := time.format(1703444325734390000)
b := time.format(1257894000000000000)
query: data.test
want_result:
a: "2023-12-24T18:58:45.734390Z"
b: "2009-11-10T23:00:00Z"
- note: with-timezone-and-no-format
data: {}
modules:
- |
package test
a := time.format([1703444325734390000, "UTC"])
b := time.format([1257894000000000000, ""])
query: data.test
want_result:
a: "2023-12-24T18:58:45.734390Z"
b: "2009-11-10T23:00:00Z"
- note: with-timezone-and-format
data: {}
modules:
- |
package test
a := time.format([1703444325734390000, "UTC", "2006-01-02T15:04:05"])
b := time.format([1257894000000000000, "", "02/01/2006 15:04"])
query: data.test
want_result:
a: "2023-12-24T18:58:45"
b: "10/11/2009 23:00"
- note: invalid-type
data: {}
modules:
- |
package test
a := time.format([1703444325734390000, "UTC", 42])
query: data.test
error: '`time.format` expects 3rd element of `ns` to be a `string`. Got `42` instead'