advantagefse / json-logic-swift

A native Swift JsonLogic implementation. This parser accepts JsonLogic rules and executes them.
MIT License
25 stars 22 forks source link

Fixed JSON to working with Date object #17

Closed alexchornyi closed 3 years ago

alexchornyi commented 3 years ago

Fixed JSON to working with Date object Fixed dateTimeHandling

csknns commented 3 years ago

Thanks for the contribution @alexchornyi.

I am a little hesitant to merge it because this JSON enum represents a JSON object and JSON does not have an representation for a Date object. So if an specific application needs to represent a date in json format I think it is better to be handled in application level. If we merge this It will break existing apps that use jsonlogic and parse dates as strings(as expected by the JSON format) in the applications domain.

Also for the Date and String extensions I think they are not part of the responsibility of the JSON module, since they solve application specific problems.

alexchornyi commented 3 years ago

How can you use custom rule for equals Date's without Date object. Here is example rule: """ { "if": [ { "var": "payload.r.0" }, { "and": [ { ">=": [ { "plusTime": [ { "var": "payload.r.0.df" }, 0, "day" ] }, { "plusTime": [ { "var": "payload.r.0.fr" }, 11, "day" ] } ] }, { "<=": [ { "plusTime": [ { "var": "payload.r.0.du" }, 0, "day" ] }, { "plusTime": [ { "var": "payload.r.0.fr" }, 180, "day" ] } ] } ] }, true ] } """

alexchornyi commented 3 years ago

not need in root master