mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
* 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
41 lines
996 B
YAML
41 lines
996 B
YAML
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
|
|
cases:
|
|
- note: parse
|
|
data: {}
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
a := time.parse_ns("%Y-%m-%dT%H:%M:%S", "2006-01-02T15:04:05")
|
|
b := time.parse_ns("%Y-%m-%d %H:%M:%S", "2015-09-05 23:56:04")
|
|
query: data.test
|
|
want_result:
|
|
a: 1136214245000000000
|
|
b: 1441497364000000000
|
|
|
|
- note: format-and-parse-back
|
|
data: {}
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
a := res {
|
|
date := time.format([1703444325734390000, "UTC", "%Y-%m-%dT%H:%M:%S%.f"])
|
|
res := time.parse_ns("%Y-%m-%dT%H:%M:%S%.f", date)
|
|
}
|
|
query: data.test
|
|
want_result:
|
|
a: 1703444325734390000
|
|
|
|
- note: invalid-type
|
|
data: {}
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
a := time.parse_ns("%Y-%m-%dT%H:%M:%S%.f", 1703444325734390000)
|
|
query: data.test
|
|
error: '`time.parse_ns` expects string argument. Got `1703444325734390000` instead'
|