IBM / JSONata4Java

Open Source Java version of JSONata
Apache License 2.0
88 stars 36 forks source link

Proposal for extension of function fromMillis #295

Closed marcioandrada closed 5 months ago

marcioandrada commented 5 months ago

Good morning,

I would like to propose an extension to function fromMillis where we can pass a TimeZone as parameter, instead of the actual offset. Currently JSONata only accepts the offset of the date to be converted (like +01:00, -02:00, etc...), but this has a problem that it doesn't cover Daylight Saving Time, i.e., it converts the date/times in a fixed offset regardless of the date being on DST or Standard time.

Therefore, my proposal is to extend or create a new function in the JSONata4Java implementation itself, that converts the date/time based on the TimeZone name (i.e., "Europe/Brussels", "America/Los_Angeles", etc...), so that it can derive the correct offset for the given date and make the conversion based on being in DST or Standard time properly. This would make this function specific for JSONata4Java and not for standard JSONata, but at least it would cover that need. I was able to create a fully JSONata-based function, but it requires a lot of JSON data to be passed as parameter and performance is really not good at all.

I already have a proposal for the Java implementation in JSONata4Java, if it is allowed I can maybe create a branch and propose my changes? How could that work, please?

Kind regards, Márcio Andrada

wnm3 commented 5 months ago

By all means feel free to create a branch and once done, create a pull request. Good luck.