AbstractTime.st
changeset 16407 67eeb7ae5eb8
parent 16365 7255d544da96
child 16475 dd2e012601bf
equal deleted inserted replaced
16406:967b6c76169a 16407:67eeb7ae5eb8
   467      (Time hours:12 minutes:0 seconds:0) meridianAbbreviation    
   467      (Time hours:12 minutes:0 seconds:0) meridianAbbreviation    
   468      (Time hours:12 minutes:0 seconds:1) meridianAbbreviation  
   468      (Time hours:12 minutes:0 seconds:1) meridianAbbreviation  
   469     "
   469     "
   470 ! !
   470 ! !
   471 
   471 
       
   472 
   472 !AbstractTime methodsFor:'abstract'!
   473 !AbstractTime methodsFor:'abstract'!
   473 
   474 
   474 hours
   475 hours
   475     "return the hour of time (0..23)"
   476     "return the hour of time (0..23)"
   476 
   477 
   586 !
   587 !
   587 
   588 
   588 - aTimeOrNumberOfSeconds
   589 - aTimeOrNumberOfSeconds
   589     "return the delta in seconds between 2 times or subtract a number of seconds."
   590     "return the delta in seconds between 2 times or subtract a number of seconds."
   590 
   591 
   591 "/    aTimeOrNumberOfSeconds isNumber ifTrue:[
       
   592 "/        ^ self species basicNew 
       
   593 "/            setMilliseconds:(self getMilliseconds - (aTimeOrNumberOfSeconds * 1000) asInteger)
       
   594 "/    ].
       
   595 "/    ^ self getSeconds - aTimeOrNumberOfSeconds getSeconds
       
   596     ^ aTimeOrNumberOfSeconds differenceFromTimestamp:self.
   592     ^ aTimeOrNumberOfSeconds differenceFromTimestamp:self.
   597 
   593 
   598     "
   594     "
   599      Timestamp now - 3600.  
   595      Timestamp now - 3600.  
   600      Time now - 3600.   
   596      Time now - 3600.   
   603      (TimeDuration fromString:'1.5hr') - (TimeDuration fromString:'1hr')   
   599      (TimeDuration fromString:'1.5hr') - (TimeDuration fromString:'1hr')   
   604 
   600 
   605      |t1 t2|
   601      |t1 t2|
   606 
   602 
   607      t1 := Timestamp now.
   603      t1 := Timestamp now.
   608      (Delay forSeconds:5) wait.
   604      Delay waitFor:10 seconds.
   609      t2 := Timestamp now.
   605      t2 := Timestamp now.
   610      Transcript showCR:('seconds passed: ' , (t2 - t1) printString).
   606      Transcript showCR:('seconds passed: ' , (t2 - t1) printString).
   611     "
   607     "
   612 !
   608 !
   613 
   609 
   898 
   894 
   899 differenceFromTimestamp:aTimestamp
   895 differenceFromTimestamp:aTimestamp
   900     "/ the correct thing to do (and I will, in the future) is to
   896     "/ the correct thing to do (and I will, in the future) is to
   901     "/ return a TimeDuration:
   897     "/ return a TimeDuration:
   902     "/
   898     "/
   903     ^ TimeDuration fromMilliseconds:(self getMilliseconds - (aTimestamp getMilliseconds))
   899     ^ TimeDuration fromMilliseconds:(aTimestamp getMilliseconds -self getMilliseconds).
       
   900 
   904     "/ which is the same as: deltaFrom:aTimestamp
   901     "/ which is the same as: deltaFrom:aTimestamp
   905     "/
   902     "/
   906     "/ however, there might be old code around, which is not be prepared for
   903     "/ however, there might be old code around, which is not be prepared for
   907     "/ getting a non-number (the seconds). Therefore, for the meantime,
   904     "/ getting a non-number (the seconds). Therefore, for the meantime,
   908     "/ we return:
   905     "/ we return:
   909 
   906 
   910     "/ ^ aTimestamp getSeconds - self getSeconds
   907     "/ ^ aTimestamp getSeconds - self getSeconds
   911 ! !
   908 ! !
       
   909 
   912 
   910 
   913 !AbstractTime methodsFor:'printing & storing'!
   911 !AbstractTime methodsFor:'printing & storing'!
   914 
   912 
   915 addPrintBindingsTo:aDictionary
   913 addPrintBindingsTo:aDictionary
   916     "private print support: add bindings for printing to aDictionary."
   914     "private print support: add bindings for printing to aDictionary."
  1226 ! !
  1224 ! !
  1227 
  1225 
  1228 !AbstractTime class methodsFor:'documentation'!
  1226 !AbstractTime class methodsFor:'documentation'!
  1229 
  1227 
  1230 version
  1228 version
  1231     ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.78 2014-04-16 22:34:52 cg Exp $'
  1229     ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.79 2014-05-07 14:33:06 stefan Exp $'
  1232 !
  1230 !
  1233 
  1231 
  1234 version_CVS
  1232 version_CVS
  1235     ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.78 2014-04-16 22:34:52 cg Exp $'
  1233     ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.79 2014-05-07 14:33:06 stefan Exp $'
  1236 ! !
  1234 ! !
  1237 
  1235