[squeak-dev] Date today versus DateAndTime today

Ron Teitelbaum ron at usmedrec.com
Thu Dec 9 17:06:38 UTC 2021


On Thu, Dec 9, 2021 at 4:40 AM Marcel Taeumel <marcel.taeumel at hpi.de> wrote:

> Hi Bernhard --
>
> Date is a Timespan while DateAndTime is not. I think we should drop the
> timezone offset when converting a DateAndTime to a Date. Yet, the class
> comment of Date reads, that there are rare cases where one would need such
> an offset. Not sure.
>

In my opinion, The result of the comparison should only consider the result
of the date with the offset applied.  While it is true that the
original date + offset might result in a different date the result should
still be true if the resulting dates are the same.  One is the result of
the date plus the offset the other is a date but they are both Functionally
equal.  The results currently are converting both dates to UTC before the
comparison.

       self asUTC hasEqualTicks: aDateAndTimeOrTimeStamp asUTC

That to me is the error.  If you wanted to make that comparison you would
do asUTC yourself to remove timezone information.

I can not fathom a reason that DateAndTime today asDate = Date today.  is
better by returning false.  Anyone worried about timezones in this instance
would use UTC or local conversions first before doing the comparison.

All the best,

Ron



> In any case, "DateAndTime today" and "Date today" have different use
> cases. If you need an accurate timestamp, use DateAndTime. If you write an
> application that needs to handle time of some sorts (including calendars
> and games), use Date, Month, Week, Year.
>
> Looking at the "STON" project, I find it strange that there are extensions
> on both DateAndTime and Date, given that this is primarily used in version
> control. You should only use DateAndTime in such scenarios.
>
> Best,
> Marcel
>
> Am 08.12.2021 23:22:03 schrieb Bernhard Pieber <bernhard at pieber.com>:
> Hi everyone,
>
> I am quite puzzled that the following answers false:
> DateAndTime today asDate = Date today.
>
> The reason seems to be the localOffsetSeconds. While DateAndTime today
> asDate has a local timezone, Date today has not. Shouldn’t this be
> consistent?
>
> The following answers false as well:
> Date today start = DateAndTime today
>
> I assume it is for the same reason.
>
> I suppose this is a feature, not a bug, but what is the reason for this
> behaviour?
>
> Cheers,
> Bernhard
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211209/46e7a4cb/attachment.html>


More information about the Squeak-dev mailing list