AbstractTime.st
changeset 16475 dd2e012601bf
parent 16407 67eeb7ae5eb8
child 16505 c285d94f2248
--- a/AbstractTime.st	Tue May 20 16:34:57 2014 +0200
+++ b/AbstractTime.st	Wed May 21 14:33:15 2014 +0200
@@ -725,6 +725,36 @@
     ^ self addSeconds:timeAmount
 !
 
+deltaFrom:aTimeOrInteger
+    "return the delta as a timeDuration between 2 timeStamps.
+     The argument is supposed to be BEFORE the receiver,
+        computes self - aTimestamp"
+
+    ^ aTimeOrInteger differenceFromTimestamp:self
+
+    "
+        Time now deltaFrom:10 minutes.
+        Time now deltaFrom:3600.
+        Time now deltaFrom:3600 seconds.
+
+        Timestamp now deltaFrom:10 minutes.
+        Timestamp now deltaFrom:3600.
+        Timestamp now deltaFrom:3600 seconds.
+    "
+
+    "
+     |t1 t2|
+
+     t1 := Timestamp now.
+     Delay waitForSeconds:0.5.
+     t2 := Timestamp now.
+     t2 deltaFrom:t1   
+    "
+
+    "Created: / 04-10-2007 / 13:34:28 / cg"
+    "Modified: / 10-07-2010 / 09:37:01 / cg"
+!
+
 subtractDays:numberOfDays
     "return a new instance of myself, numberOfDays before."
 
@@ -1226,10 +1256,10 @@
 !AbstractTime class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.79 2014-05-07 14:33:06 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.80 2014-05-21 12:33:15 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.79 2014-05-07 14:33:06 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.80 2014-05-21 12:33:15 stefan Exp $'
 ! !