json-logic icon indicating copy to clipboard operation
json-logic copied to clipboard

Date and time handling

Open larsbuch opened this issue 3 years ago • 3 comments

These business rules defined in json logic is missing one essential thing as far as I see it that is date time handling in rules. I would love to be able to expres business rules in a generic way for frontend and backend and documentation but date and time is a part of the core. ISO date and time is the only needed support as all languages have conversion support.

Is there a suggestion of how to handle that?

larsbuch avatar Dec 29 '20 07:12 larsbuch

+1 as I have also few use cases for date validation !!

atulagrawal avatar Jun 09 '21 02:06 atulagrawal

This is an important feature for Open Feature and Flagd support

RuairiSpain avatar Apr 08 '23 22:04 RuairiSpain

Actually this does work, but if you are looking for a date rule, the data payload needs to match the variable names you set in the rules. I so if you want a beta test rule for feature flags, just send in the current date for both start and end.

Rule: { "and" : [ {">=" : [ { "var" : "start" }, "2023-03-01" ] }, {"<=" : [ { "var" : "end" }, "2023-04-01" ] } ] }

Data: { "start" : "2023-03-01", "end" : "2023-03-01"}

RuairiSpain avatar Apr 08 '23 23:04 RuairiSpain