[squeak-dev] Timespan>>datesDo: - is this a bug?

Chris Cunningham cunningham.cb at gmail.com
Sat May 11 18:04:55 UTC 2019

That does explain it.  So, datesDo: is fine.

Timespan>>to: is the method at issue.  The right-open intenterval is what
tripped me up. Other implementations of #to: are right closed: (1 to: 2)
includes 2, for instance, whereas (Date yesterday to: Date today) does not
include today.

Time to: makes sense to me: '01:00:00' asTime to: '02:00:00' asTime being 1
hour makes sense to me, since it is a particular point in time to another
particular point in time.
The Day to Day - I guess just assuming the 2nd day means the beginning of
the day instead of the end of the day is what gets me.

I'd excpect Date today to: Date today to be today - not an empty timespan.

Maybe I just need to get over it.
But what I'd expect is the the end part of the timespan #to: to use the end
of the ending timespan,if possible.


On Fri, May 10, 2019 at 3:40 PM Levente Uzonyi <leves at caesar.elte.hu> wrote:

> 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
> >
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190511/08d0c26c/attachment.html>

More information about the Squeak-dev mailing list