[squeak-dev] Timespan>>datesDo: - is this a bug?
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 := 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.
I wrote a mail about this just two months ago. 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.
More information about the Squeak-dev