printing/storing; ms handling
authorClaus Gittinger <cg@exept.de>
Wed, 18 Jul 2007 14:16:40 +0200
changeset 1891 af37298a4b38
parent 1890 5384a03a9342
child 1892 9a7062768503
printing/storing; ms handling
TimeDuration.st
--- a/TimeDuration.st	Wed Jul 18 13:54:57 2007 +0200
+++ b/TimeDuration.st	Wed Jul 18 14:16:40 2007 +0200
@@ -51,6 +51,18 @@
     "
 !
 
+fromMilliseconds:millisecondsInterval
+    "redefined to disable wrapping at 24hours."
+
+    ^ self new setMilliseconds:millisecondsInterval
+
+    "
+     TimeDuration fromMilliseconds:500  
+    "
+
+    "Created: / 18-07-2007 / 13:56:25 / cg"
+!
+
 fromMinutes:minutesInterval
     ^ self new setSeconds:(minutesInterval * 60)
 
@@ -159,7 +171,7 @@
             str skipSeparators.
             str atEnd
         ] whileFalse.
-        self fromSeconds:seconds
+        self fromMilliseconds:(seconds*1000+millis) rounded asInteger.
     ] on:Error do:exceptionBlock.
 
     "
@@ -172,7 +184,7 @@
      TimeDuration readFrom:'3ms'     
     "
 
-    "Modified: / 18-07-2007 / 13:43:13 / cg"
+    "Modified: / 18-07-2007 / 14:10:04 / cg"
 ! !
 
 !TimeDuration class methodsFor:'format strings'!
@@ -271,14 +283,25 @@
         (millis = 0) ifTrue:[
             fmt := fmt , '%Ss'
         ] ifFalse:[
-            fmt := fmt , '%S.%is'
+            secs = 0 ifTrue:[
+                fmt := fmt , '%Ims'
+            ] ifFalse:[
+                fmt := fmt , '%S.%is'
+            ]
+        ].
+    ] ifFalse:[
+        fmt isEmpty ifTrue:[
+            fmt := '%Ss'
         ].
     ].
+
     ^ self
         printOn:aStream 
         format:fmt.
 
     "
+     TimeDuration hours:0 minutes:0 seconds:0 millis:12       
+
      TimeDuration hours:0 minutes:0 seconds:0 millis:123       
      TimeDuration hours:0 minutes:0 seconds:10 millis:123       
      TimeDuration hours:0 minutes:33 seconds:0 millis:123       
@@ -300,6 +323,8 @@
      (TimeDuration hours:10000 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s'      
      (TimeDuration hours:1000000 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s'      
     "
+
+    "Modified: / 18-07-2007 / 14:06:17 / cg"
 ! !
 
 !TimeDuration methodsFor:'private'!
@@ -356,5 +381,5 @@
 !TimeDuration class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Attic/TimeDuration.st,v 1.17 2007-07-18 11:54:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Attic/TimeDuration.st,v 1.18 2007-07-18 12:16:40 cg Exp $'
 ! !