[Pharo-project] Timespan #intersection: yields wrong result
johan at inceptive.be
Wed May 4 08:50:59 CEST 2011
No, and it seems I have mixed up Chronology and Chronos.
I just got an answer from Alan Lovejoy confirming that my snippet works correct in the Chronos implementation (which is not the standard date/time library).
So, I'm still wondering why this is not the case in Chronology.
I will definitely check out Chronos and Aconcagua now. Stupid me that I did not see that :-(
On 03 May 2011, at 22:51, Stéphane Ducasse wrote:
> BTW johan did you also check aconcagua?
> On May 3, 2011, at 7:25 PM, Johan Brichau wrote:
>> 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