Files
regorus/tests/interpreter/cases/builtins/time/format.yaml
Burak d2eb3ecd1f Implement most of the builtin time module (#82)
* Implement builtin `time.add_date` method

* Implement builtin `time.clock` method

* Implement builtin `time.date` method

* Implement builtin `time.diff` method

* Implement builtin `time.format` method

* Migrate `time.now_ns` to `chrono`

* Implement builtin `time.parse_ns` method

* Implement builtin `time.parse_rfc3339_ns` method

* Implement builtin `time.weekday` method

* Add conditional `test` module for OPA tests

* Cache result of `time.now_ns`

* Fail in strict mode if timestamp is outside of range

* Add `ensure_i32` util

* Move `diff_between_datetimes` into its own file and include appropriate license
2023-12-31 17:07:39 -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", "%Y-%m-%dT%H:%M:%S"])
b := time.format([1257894000000000000, "", "%d/%m/%Y %H:%M"])
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'