[Pharo-project] Timespan #intersection: yields wrong result

Stéphane Ducasse stephane.ducasse at inria.fr
Tue May 3 22:51:27 CEST 2011


BTW johan did you also check aconcagua?


Stef

On May 3, 2011, at 7:25 PM, Johan Brichau wrote:

> Hi,
> 
> I traced a bug when working with timespans to the following issue illustrated in the code snippet below. 
> The last expression in the snippet yields false, although it should yield true (imho).
> 
> 	|start end span|
> 	start :=DateAndTime now.
> 	end := start + 1 hour.
> 	span := Timespan starting: start ending: end.
> 	(span intersection: span) = span  --> false
> 
> I think that the intersection of a span with itself, should be itself. The origin of the problem is that Timespan>>intersection: creates a new timespan roughly as follows:
> 
> 	Timespan starting: aBegin ending: self end.
> 
> But Timespan>>end returns the end time of the timespan minus the clockprecision. As such, the intersecting span is a nanosecond shorter than the one we would expect. This eventually yields wrong results when working with timespans.
> 
> The real question now is: should the implementation of Timespan>>intersection be changed -or- should Timespan>>end really return the (non-included) end time (that was passed when constructing it)?
> 
> I sent this email to bugs at chronos-st.org, but a discussion here probably will not hurt either.
> 
> Best regards
> Johan Brichau




More information about the Pharo-project mailing list