In our applications we use UTC timestamps/dates wherever possible for
this exact reason.
You should rightfully fear the midnight in local time, and storing local
dates/times in your database should imho be avoided wherever possible,
unless it is just used for human readability debugging purposes.
I don't however see this Groovy extension to lead to the problems you
allude to, it is just for the case when you have a Date, you can still
compare it conveniently to a DateTime, store them together in a sorted
collection with some plausible default behavior, etc.
As I have said before, nobody is suggesting you start building your
application mixing Date and DateTime objects for the heck of it, it
would in my eyes just be if you do not control the return value of a
call, legacy reasons, stuff like that.
Cheers,
mg
On 18/11/2021 15:10, Alessio Stalla wrote:
Dates are not something to mess with lightheartedly. All kinds of
weird exceptions exist. In some dates in some timezones, midnight
(i.e. 00:00) does not exist:
https://stackoverflow.com/questions/18489927/a-day-without-midnight
These kinds of implicit conversions may look like they simplify things
but actually they hide nasty bugs under the carpet, that you'll only
discover when it's Jan 1st 2031 and you get angry calls in the morning
while you're hungover, or when your first customer who was born at, I
don't know, 1978-08-01 at midnight in the Fiji islands signs up into
the application.
Please, don't do that. MySQL did that, and I've already suffered
because of it.
On Thu, 18 Nov 2021 at 14:22, Jochen Theodorou <blackd...@gmx.org> wrote:
On 17.11.21 20:28, MG wrote:
[...]
> 3. I have never encountered any other assumption than the one
that a
> Date carries the implicit time of midnight
(00:00:00.000...). What
> other time would one logically pick, given that time
intervals are
> by convention typically closed on the left and open on the
right ?
But you have here already trouble. you can take the start of the
day, or
the end of the day. both is midnight, both based on the same date, but
they are basically 24h apart. In my last project we mostly used end of
the day for example. And in some parts actually 2:00 in the morning,
because it is the time to run after some processes... which did not
proof to be a good idea btw.
bye Jochen