mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
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
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
cases:
|
||||
- note: without-timezone
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
|
||||
a := time.diff(1703444325734390000, 1257894000000000000)
|
||||
query: data.test
|
||||
want_result:
|
||||
a:
|
||||
- 14
|
||||
- 1
|
||||
- 13
|
||||
- 19
|
||||
- 58
|
||||
- 45
|
||||
|
||||
- note: with-timezone
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
|
||||
a := time.diff([1703444325734390000, "UTC"], [1257894000000000000, ""])
|
||||
query: data.test
|
||||
want_result:
|
||||
a:
|
||||
- 14
|
||||
- 1
|
||||
- 13
|
||||
- 19
|
||||
- 58
|
||||
- 45
|
||||
|
||||
- note: tz1-greater-than-tz2
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
|
||||
a := time.diff(1257894000000000000, 1703444325734390000)
|
||||
query: data.test
|
||||
want_result:
|
||||
a:
|
||||
- 14
|
||||
- 1
|
||||
- 13
|
||||
- 19
|
||||
- 58
|
||||
- 45
|
||||
|
||||
- note: invalid-type
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
|
||||
a := time.diff("1703444325734390000", 1257894000000000000)
|
||||
query: data.test
|
||||
error: '`time.diff` expects `ns` to be a `number` or `array[number, string]`. Got `"1703444325734390000"` instead'
|
||||
Reference in New Issue
Block a user