TimeDuration.st
changeset 22519 040b32959a91
parent 22493 0232ebe18eb8
child 22620 c77e738e5d23
equal deleted inserted replaced
22518:98805ee7fff3 22519:040b32959a91
  1199                     "/ only show millis if the number of seconds is small
  1199                     "/ only show millis if the number of seconds is small
  1200                     overAllSeconds := self asSeconds.
  1200                     overAllSeconds := self asSeconds.
  1201                     overAllSeconds > 2 ifTrue:[
  1201                     overAllSeconds > 2 ifTrue:[
  1202                         overAllSeconds > 10 ifTrue:[
  1202                         overAllSeconds > 10 ifTrue:[
  1203                             overAllSeconds > 300 ifTrue:[
  1203                             overAllSeconds > 300 ifTrue:[
       
  1204                                "/ no decimal above 300 seconds
  1204                                 fmt := fmt , '%Ss'
  1205                                 fmt := fmt , '%Ss'
  1205                             ] ifFalse:[
  1206                             ] ifFalse:[
       
  1207                                "/ 1 decimals up to 300 seconds
  1206                                 fmt := fmt , '%S.%(milli1)s'
  1208                                 fmt := fmt , '%S.%(milli1)s'
  1207                             ]
  1209                             ]
  1208                         ] ifFalse:[
  1210                         ] ifFalse:[
       
  1211                            "/ 2 decimals up to 10seconds
  1209                             fmt := fmt , '%S.%(milli2)s'
  1212                             fmt := fmt , '%S.%(milli2)s'
  1210                         ]
  1213                         ]
  1211                     ] ifFalse:[
  1214                     ] ifFalse:[
       
  1215                         "/ millis up to 2seconds
  1212                         fmt := fmt , '%S.%is'
  1216                         fmt := fmt , '%S.%is'
  1213                     ]
  1217                     ]
  1214                 ]
  1218                 ]
  1215             ]
  1219             ]
  1216         ].
  1220         ].
  1222 
  1226 
  1223     ^ fmt.
  1227     ^ fmt.
  1224 
  1228 
  1225     "
  1229     "
  1226      (TimeDuration hours:0 minutes:0 seconds:0 milliseconds:12) formatForPrinting
  1230      (TimeDuration hours:0 minutes:0 seconds:0 milliseconds:12) formatForPrinting
       
  1231      (TimeDuration hours:0 minutes:0 seconds:2 milliseconds:12) formatForPrinting 
       
  1232      (TimeDuration hours:0 minutes:0 seconds:8 milliseconds:12) formatForPrinting  
       
  1233      (TimeDuration hours:0 minutes:0 seconds:10 milliseconds:12) formatForPrinting  
  1227 
  1234 
  1228      (TimeDuration hours:0 minutes:0 seconds:0 milliseconds:123) formatForPrinting
  1235      (TimeDuration hours:0 minutes:0 seconds:0 milliseconds:123) formatForPrinting
  1229      (TimeDuration hours:0 minutes:0 seconds:10 milliseconds:123) formatForPrinting
  1236      (TimeDuration hours:0 minutes:0 seconds:10 milliseconds:123) formatForPrinting
  1230      (TimeDuration hours:0 minutes:33 seconds:0 milliseconds:123) formatForPrinting
  1237      (TimeDuration hours:0 minutes:33 seconds:0 milliseconds:123) formatForPrinting
  1231      (TimeDuration hours:2 minutes:0 seconds:0 milliseconds:123) formatForPrinting
  1238      (TimeDuration hours:2 minutes:0 seconds:0 milliseconds:123) formatForPrinting