arithmetic on time-durations
authorClaus Gittinger <cg@exept.de>
Thu, 04 Oct 2007 15:45:16 +0200
changeset 1896 fc107aed9bb9
parent 1895 f2ca9e7fdb3c
child 1897 d13a5cbd9250
arithmetic on time-durations
TimeDuration.st
--- a/TimeDuration.st	Tue Sep 25 11:21:45 2007 +0200
+++ b/TimeDuration.st	Thu Oct 04 15:45:16 2007 +0200
@@ -239,6 +239,34 @@
     ^ timeEncoding \\ 1000
 ! !
 
+!TimeDuration methodsFor:'arithmetic'!
+
++ aTimeDurationOrNumberOfSeconds
+    "return a new timeDuration"
+
+    aTimeDurationOrNumberOfSeconds isNumber ifTrue:[
+        ^ self species basicNew 
+            setMilliseconds:(self getMilliseconds + (aTimeDurationOrNumberOfSeconds * 1000) asInteger)
+    ].
+    ^ self species basicNew
+        setMilliseconds:(self getMilliseconds + aTimeDurationOrNumberOfSeconds getMilliseconds)
+
+    "Created: / 04-10-2007 / 14:12:40 / cg"
+!
+
+- aTimeDurationOrNumberOfSeconds
+    "return a new timeDuration"
+
+    aTimeDurationOrNumberOfSeconds isNumber ifTrue:[
+        ^ self species basicNew 
+            setMilliseconds:(self getMilliseconds - (aTimeDurationOrNumberOfSeconds * 1000) asInteger)
+    ].
+    ^ self species basicNew
+        setMilliseconds:(self getMilliseconds - aTimeDurationOrNumberOfSeconds getMilliseconds)
+
+    "Created: / 04-10-2007 / 14:12:29 / cg"
+! !
+
 !TimeDuration methodsFor:'converting'!
 
 asTime
@@ -415,5 +443,5 @@
 !TimeDuration class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Attic/TimeDuration.st,v 1.21 2007-09-06 15:31:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Attic/TimeDuration.st,v 1.22 2007-10-04 13:45:16 cg Exp $'
 ! !