Files
regorus/tests/interpreter/cases/builtins/time/date.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

47 lines
898 B
YAML

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cases:
- note: without-timezone
data: {}
modules:
- |
package test
a := time.date(1703444325734390000)
query: data.test
want_result:
a:
- 2023
- 12
- 24
- note: with-utc-timezone
data: {}
modules:
- |
package test
a := time.date([1257894000000000000, "UTC"])
b := time.date([1703896119423491000, ""])
query: data.test
want_result:
a:
- 2009
- 11
- 10
b:
- 2023
- 12
- 30
- note: invalid-type
data: {}
modules:
- |
package test
a := time.date("1703444325734390000")
query: data.test
error: '`time.date` expects `ns` to be a `number` or `array[number, string]`. Got `"1703444325734390000"` instead'