comments
authorClaus Gittinger <cg@exept.de>
Sat, 06 Sep 2008 12:45:33 +0200
changeset 2036 983bf1ca0456
parent 2035 77b2cab133c3
child 2037 5257cf7c7672
comments
TimeDuration.st
--- a/TimeDuration.st	Sat Sep 06 12:35:24 2008 +0200
+++ b/TimeDuration.st	Sat Sep 06 12:45:33 2008 +0200
@@ -617,7 +617,7 @@
 !
 
 printAsApproximationOn:aStream
-    "append a user printed representation of the receiver to aStream.
+    "append a human readable printed representation of the receiver to aStream.
      The format is meant for a human and does not give all information;
      especially, useless detail is hidden.
      This means, that seconds are rounded or hidden, if the dT is more than a few minutes;
@@ -647,7 +647,7 @@
 !
 
 printOn:aStream
-    "append a user printed representation of the receiver to aStream.
+    "append a human readable printed representation of the receiver to aStream.
      The format is suitable for a human - not meant to be read back."
 
     ^ self
@@ -680,6 +680,33 @@
     "
 
     "Modified: / 18-07-2007 / 14:06:17 / cg"
+!
+
+printStringForApproximation
+    "return a human readable printed representation of the receiver to aStream.
+     The format is meant for a human and does not give all information;
+     especially, useless detail is hidden.
+     This means, that seconds are rounded or hidden, if the dT is more than a few minutes;
+     minutes rounded into the hour or hidden, if its more than a few hours etc.
+     The way this is done is pure magic heuristics - let me know, if you have a better algorithm."
+
+    ^ self
+        printStringFormat:(self formatForApproximatePrinting).
+
+    "
+     (TimeDuration hours:0 minutes:0 seconds:0 milliseconds:123) printStringForApproximation
+     (TimeDuration hours:0 minutes:0 seconds:10 milliseconds:123) printStringForApproximation
+     (TimeDuration hours:0 minutes:33 seconds:0 milliseconds:123) printStringForApproximation
+     (TimeDuration hours:2 minutes:0 seconds:0 milliseconds:123) printStringForApproximation
+     (TimeDuration hours:2 minutes:33 seconds:0 milliseconds:123) printStringForApproximation
+     (TimeDuration hours:100 minutes:33 seconds:0 milliseconds:123) printStringForApproximation
+     (TimeDuration hours:10000 minutes:33 seconds:0 milliseconds:123) printStringForApproximation
+     (TimeDuration hours:1000000 minutes:33 seconds:0 milliseconds:123) printStringForApproximation
+
+     (TimeDuration hours:2 minutes:33 seconds:0) printStringForApproximation
+     (TimeDuration hours:2 minutes:0 seconds:0) printStringForApproximation
+     (TimeDuration hours:24 minutes:0 seconds:0) printStringForApproximation
+    "
 ! !
 
 !TimeDuration methodsFor:'private'!
@@ -743,7 +770,7 @@
 !TimeDuration class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Attic/TimeDuration.st,v 1.31 2008-09-06 10:35:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Attic/TimeDuration.st,v 1.32 2008-09-06 10:45:33 cg Exp $'
 ! !
 
 TimeDuration initialize!