camunda / feel-scala

FEEL parser and interpreter written in Scala
https://camunda.github.io/feel-scala/
Apache License 2.0
119 stars 46 forks source link

Should compare date and time values with different time zones #767

Open till-stadtler opened 7 months ago

till-stadtler commented 7 months ago

Describe the bug Date and time values can be specified by adding a time zone:

yyyy-MM-dd'T'HH:mm:ss+/-HH:mm 
yyyy-MM-dd'T'HH:mm:ss@ZoneId

These date and time values are comparable, as they describe unambiguous instants. This is reflected in the fact that the comparison does not result in null.

Here are examples of buggy behavior when comparing date and time values with time zones.

Using the same time zone via +01:00 and @Europe/Paris:

date and time("2023-03-06T16:23:00+01:00")
// returns: "2023-03-06T16:23:00+01:00"
date and time("2023-03-06T16:23:00@Europe/Paris")
// returns: "2023-03-06T16:23:00+01:00"

date and time("2023-03-06T16:23:00+01:00") = date and time("2023-03-06T16:23:00@Europe/Paris")
// returns: false
// expected: true
date and time("2023-03-06T16:23:00+01:00") < date and time("2023-03-06T16:23:00@Europe/Paris")
// returns: true
// expected: false

Using different time zones describing the same instant:

date and time("2023-03-06T16:23:00+01:00")
// returns: "2023-03-06T16:23:00+01:00"
date and time("2023-03-06T17:23:00+02:00")
// returns: "2023-03-06T17:23:00+02:00"

date and time("2023-03-06T16:23:00+01:00") = date and time("2023-03-06T17:23:00+02:00")
// returns: false
// expected: true
date and time("2023-03-06T16:23:00+01:00") < date and time("2023-03-06T17:23:00+02:00")
// returns: true
// expected: false

To Reproduce Steps to reproduce the behavior: Enter the expressions above in the FEEL Playground

Expected behavior Comparing date and time values with the same time zones described via +01:00 and @Europe/Paris should return the correct values when compared. Comparing date time time values with different time zones (+02:00/+01:00, or otherwise) should return the correct values when compared.

Environment

saig0 commented 7 months ago

This issue is related to https://github.com/camunda/feel-scala/issues/560.