TimeDuration.st
changeset 22891 ac18d6513ef8
parent 22887 4ed210df350c
child 22917 cefccd43b35a
equal deleted inserted replaced
22890:0401fecb9c89 22891:ac18d6513ef8
  2087 !
  2087 !
  2088 
  2088 
  2089 setNanoseconds:nanos
  2089 setNanoseconds:nanos
  2090     "set my duration given nanoseconds."
  2090     "set my duration given nanoseconds."
  2091 
  2091 
  2092     |restNanos|
  2092     |millis restNanos|
  2093 
  2093 
       
  2094     millis := nanos // (1000*1000).
  2094     nanos isInteger ifTrue:[
  2095     nanos isInteger ifTrue:[
  2095         timeEncoding := nanos // 1000000.
  2096         timeEncoding := millis.
  2096         additionalPicoseconds := (nanos \\ 1000) * 1000 
  2097         restNanos := nanos \\ (1000*1000).
       
  2098         additionalPicoseconds := restNanos * 1000 
  2097     ] ifFalse:[
  2099     ] ifFalse:[
  2098         timeEncoding := nanos // (1000*1000).
  2100         timeEncoding := millis.
  2099         restNanos := nanos - (timeEncoding * (1000*1000)).
  2101         restNanos := nanos - (millis * (1000*1000)).
  2100         additionalPicoseconds := (restNanos * 1000) rounded asInteger.
  2102         additionalPicoseconds := (restNanos * 1000) rounded asInteger.
  2101     ].
  2103     ].
  2102 
  2104 
  2103     "
  2105     "
  2104      self new setMicroseconds:4
  2106      self new setMicroseconds:4
  2105      self new setNanoseconds:4
  2107      self new setNanoseconds:4
       
  2108      self new setNanoseconds:4000
       
  2109      self new setNanoseconds:4000000
       
  2110      self new setNanoseconds:40000000
  2106      self new setNanoseconds:0.1
  2111      self new setNanoseconds:0.1
  2107     "
  2112     "
  2108 
  2113 
  2109     "Modified: / 18-07-2007 / 13:44:16 / cg"
  2114     "Modified: / 18-07-2007 / 13:44:16 / cg"
  2110 !
  2115 !