Time seconds in 3.10

Keith Hodges keith_hodges at yahoo.co.uk
Sat Dec 8 21:35:42 UTC 2007


Jimmie Houchin wrote:
> Before Squeak 3.10
>
> Time now seconds.
>
> returned a SmallInteger.
>
> Now it returns a Fraction.
>
> This was discovered in Seaside when I was using 3.10 and encountered a DNU.
>
>   

It has to be said that the time is set via a fairly roundabout route
which could be simplified somewhat
in the light of recent changes in 3.10 which now has a millisecondClock.

The cuprit is the following code

Duration-seconds
    "Answer the number of seconds the receiver represents."

    ^ (seconds rem: SecondsInMinute) + (nanos / NanosInSecond)

which can be fixed with the follwoing small change
  
Duration-seconds
    "Answer the number of whole seconds the receiver represents."

    ^ (seconds rem: SecondsInMinute) + (nanos // NanosInSecond)

assuming that other users of #seconds are also expecting an integer result.

best regards

Keith





More information about the Squeak-dev mailing list