Dates and Time in JsonLogic: best practices. #38
Replies: 1 comment 6 replies
-
Hey there! Some FlavorWanted to add a bit of context early on; (this does not dispute what's being communicated). For comparison operators, we've had some discussion over here: https://github.com/orgs/json-logic/discussions/23#discussioncomment-12111210 Essentially, while we encourage JSON Logic implementations to support language idiomatic constructs ( TimeWe've had some side discussions about time in the past on the CNCF Slack, ![]() My thoughts are:
For example, instead of introducing I would also recommend we take a look at something like Operators we would probably consider:
I think the operators should support both numbers (defined as unix time in ms) and ISO8601. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I haven’t found a concise guide on website for handling dates/time calculation in JsonLogic and would love to sanity-check the approach.
A common business check example: “User is over 21., it's age > 21 years”
Where time.minus_21y_iso is computed upstream as “now - 21 calendar years” and all dates are YYYY-MM-DD (UTC, day precision).
This works, but it adds ceremony because core JsonLogic lacks date/time operators. In practice we have to push precomputed values (e.g., time.minus_21y_iso) into the data just to express ‘minus 21 year’ or force to write custom date/time operators. I believe many users expect first-class support for routine date checks when they choose a production-ready DSL for rules (JsonLogic).
First Step
Before going into details I just want to gauge interest: Is there interest in standardizing a minimal approach?
If there’s willingness to move in either direction, I’m happy to help shape a concrete proposal.
Prior threads / references
Date and time handling (core repo): Date and time handling jwadhams/json-logic#27
[Feature] support dates (json-logic-js): [Feature] support dates jwadhams/json-logic-js#6
Official ops (no date ops in core): https://jsonlogic.com/operations.html
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions