[squeak-dev] Timespan>>datesDo: - is this a bug?
Levente Uzonyi
leves at caesar.elte.hu
Fri May 10 22:40:12 UTC 2019
On Fri, 10 May 2019, Chris Cunningham wrote:
> So, this code: Date today asMonth datesDo: [:date| Transcript cr; show: date yyyymmdd]
> prints out each day in the month. That is what I'd expect.
>
> This code:
> |mth|
> mth := Date today asMonth.
> (mth start asDate to: mth end asDate) datesDo: [:date| Transcript cr; show: date yyyymmdd]
> does not print the last date.
>
> This has bitten me. If I add a nanosecond onto the end date (mth end asDate + 1) it does include the last date - but that is ugly. And dangerous if I have other code that carefully picks the following date start to work around this oddity.
>
> Thoughts?
I wrote a mail about this just two months ago[1]. Timespan, unlike
Interval, is a right-open interval. It has to be in order to have the
expected length. Date(Timespan) >> #to: will create a Timespan.
Levente
[1] http://forum.world.st/Testing-out-new-UTCDateAndTime-in-Squeak-5-3-alpha-td5096623.html
>
> -cbc
>
>
More information about the Squeak-dev
mailing list
|