Here, we represent `java.time.LocalDate` as a `java.time.LocalDateTime` at
midnight.

Just off the top of my head, should the LocalDate match LocalDateTime only at midnight? Or should it match any point in time during that date? Surely it's April fool's day for the entire duration of April 1st?

BR; Haakon Hansen, Norway

Den 2021-11-17 12:28, skrev Søren Berg Glasius:
I think this is a very good idea, and give a +1 for the idea and
implementation.

Best regards / Med venlig hilsen,
Søren Berg Glasius

Hedevej 1, Gl. Rye, 8680 Ry, Denmark
Mobile: +45 40 44 91 88, Skype: sbglasius
--- Press ESC once to quit - twice to save the changes.


Den tir. 16. nov. 2021 kl. 15.24 skrev ssz <sss.z...@gmail.com>:


Hello everyone,

Before creating a PR (or\and an issue in Jira) I would like to discuss a
possible feature.

In our product we need the ability to compare `java.time.LocalDate` and `java.time.LocalDateTime` objects easily without knowing the exact type. For this we have historical reasons: we have a groovy-based engine and a
lot of client scripts with date comparison.
Until recently, we used a customized version of joda-time, that allows
such operations.
As practice has shown, it was very convenient.
But now for some reasons we have decided to abandon joda-time in favor of
pure java-time.
So, in order not to break anyone's scripts it would be nice for us if
groovy could support comparisons of those date-objects out of the box.

To demonstrate what I mean here is a draft:


https://github.com/greendatasoft/groovy/commit/c55d722e6b6ead9d6e0123835c62a5fa4f525ffe

Here, we represent `java.time.LocalDate` as a `java.time.LocalDateTime` at
midnight.
It seems this way can't break any code, and at the same time it would be
user-friendly.
But for those who have weird logic with exception handling, there is a
"groovy.compare.local-date-and-datetime" option, which allows to return
back the original behaviour.

Please tell me what you think.
Can I proceed with PR?
Or maybe there is a better way to customize groovy to achieve the same
behaviour?

Reply via email to