Move printOn:format: to AbstractTime
authorStefan Vogel <sv@exept.de>
Wed, 01 Sep 1999 20:18:31 +0200
changeset 4649 3eaf75dd8973
parent 4648 2b8bba444185
child 4650 0a8d9f7a38ef
Move printOn:format: to AbstractTime
AbstrTime.st
AbstractTime.st
Time.st
--- a/AbstrTime.st	Wed Sep 01 17:10:07 1999 +0200
+++ b/AbstrTime.st	Wed Sep 01 20:18:31 1999 +0200
@@ -406,6 +406,107 @@
 
 ! !
 
+!AbstractTime methodsFor:'printing & storing'!
+
+printOn:aStream format:aFormatString
+    "print using a format string;
+     valid format items are:
+        %h      hours, 00..23 (i.e. european)  0-padded to length 2
+        %u      hours, 00..12 (i.e. us)        0-padded to length 2
+        %m      minutes, 00..59                0-padded to length 2
+        %s      seconds, 00..59                0-padded to length 2
+        %a      am/pm
+
+     special:
+        %H      24-hours - unpadded
+        %U      12-hours - unpadded
+        %M      minutes - unpadded
+        %S      seconds - unpadded
+        %A      AM/PM   - uppercase
+    "
+
+    aStream nextPutAll:(self printStringFormat:aFormatString)
+
+    "
+     Time now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
+     Time now printOn:Transcript format:'%H:%m:%s'   . Transcript cr.      
+     Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr.   
+     Time now printOn:Transcript format:'%h:%m'      . Transcript cr. 
+     Time now printOn:Transcript format:'%H:%m %A'   . Transcript cr.
+     Time now printOn:Transcript format:'minutes:%M seconds:%S'   . Transcript cr.
+    "
+
+    "Modified: 22.2.1996 / 16:58:30 / cg"
+!
+
+printStringFormat:aFormatString
+    "print using a format string;
+     valid format items are:
+        %h      hours, 00..23 (i.e. european)  0-padded to length 2
+        %u      hours, 00..12 (i.e. us)        0-padded to length 2
+        %m      minutes, 00..59                0-padded to length 2
+        %s      seconds, 00..59                0-padded to length 2
+        %a      am/pm
+
+     special:
+        %H      24-hours - unpadded
+        %U      12-hours - unpadded
+        %M      minutes - unpadded
+        %S      seconds - unpadded
+        %A      AM/PM   - uppercase
+
+        %t      seconds within hour  (unpadded)
+        %T      seconds from midNight  (unpadded)
+    "
+
+    |dict hours minutes seconds usHours ampm s|
+
+    hours := self hours.
+    minutes := self minutes.
+    seconds := self seconds.
+
+    hours // 12 == 0 ifTrue:[
+        ampm := 'am'.
+    ] ifFalse:[
+        ampm := 'pm'.
+    ].
+    usHours := hours.
+    usHours ~~ 0 ifTrue:[
+        usHours := usHours - 1 \\ 12 + 1.
+    ].
+
+    dict := IdentityDictionary new.
+    dict at:$H put:(s := hours printString).
+    dict at:$h put:(s leftPaddedTo:2 with:$0).
+    dict at:$U put:(s := usHours printString).
+    dict at:$u put:(s leftPaddedTo:2 with:$0).
+    dict at:$M put:(s := minutes printString).
+    dict at:$m put:(s leftPaddedTo:2 with:$0).
+    dict at:$S put:(s := seconds printString).
+    dict at:$s put:(s leftPaddedTo:2 with:$0).
+    dict at:$t put:(seconds * minutes) printString.
+    dict at:$T put:(seconds * minutes * hours) printString.
+    dict at:$a put:ampm.
+    dict at:$A put:ampm asUppercase.
+
+    ^ (aFormatString expandPlaceholdersWith:dict)
+
+    "
+     Time now printStringFormat:'%U:%m:%s %a'   
+
+     Time now printStringFormat:'%h:%m:%s'     
+     Time now printStringFormat:'%H:%m:%s'      
+     Time now printStringFormat:'%u:%m:%s %a'   
+     Time now printStringFormat:'%h:%m'         
+     Time now printStringFormat:'%H:%m %A'     
+     Time now printStringFormat:'%m minutes after %U %a'     
+     Time now printStringFormat:'%t seconds after %U %a'     
+     Time now printStringFormat:'%T seconds from midNight'     
+    "
+
+    "Modified: 22.2.1996 / 16:58:30 / cg"
+! !
+
 !AbstractTime methodsFor:'private'!
 
 fromOSTime:osTime
@@ -455,5 +556,5 @@
 !AbstractTime class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/AbstrTime.st,v 1.15 1998-05-22 10:47:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/AbstrTime.st,v 1.16 1999-09-01 18:18:03 stefan Exp $'
 ! !
--- a/AbstractTime.st	Wed Sep 01 17:10:07 1999 +0200
+++ b/AbstractTime.st	Wed Sep 01 20:18:31 1999 +0200
@@ -406,6 +406,107 @@
 
 ! !
 
+!AbstractTime methodsFor:'printing & storing'!
+
+printOn:aStream format:aFormatString
+    "print using a format string;
+     valid format items are:
+        %h      hours, 00..23 (i.e. european)  0-padded to length 2
+        %u      hours, 00..12 (i.e. us)        0-padded to length 2
+        %m      minutes, 00..59                0-padded to length 2
+        %s      seconds, 00..59                0-padded to length 2
+        %a      am/pm
+
+     special:
+        %H      24-hours - unpadded
+        %U      12-hours - unpadded
+        %M      minutes - unpadded
+        %S      seconds - unpadded
+        %A      AM/PM   - uppercase
+    "
+
+    aStream nextPutAll:(self printStringFormat:aFormatString)
+
+    "
+     Time now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
+     Time now printOn:Transcript format:'%H:%m:%s'   . Transcript cr.      
+     Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr.   
+     Time now printOn:Transcript format:'%h:%m'      . Transcript cr. 
+     Time now printOn:Transcript format:'%H:%m %A'   . Transcript cr.
+     Time now printOn:Transcript format:'minutes:%M seconds:%S'   . Transcript cr.
+    "
+
+    "Modified: 22.2.1996 / 16:58:30 / cg"
+!
+
+printStringFormat:aFormatString
+    "print using a format string;
+     valid format items are:
+        %h      hours, 00..23 (i.e. european)  0-padded to length 2
+        %u      hours, 00..12 (i.e. us)        0-padded to length 2
+        %m      minutes, 00..59                0-padded to length 2
+        %s      seconds, 00..59                0-padded to length 2
+        %a      am/pm
+
+     special:
+        %H      24-hours - unpadded
+        %U      12-hours - unpadded
+        %M      minutes - unpadded
+        %S      seconds - unpadded
+        %A      AM/PM   - uppercase
+
+        %t      seconds within hour  (unpadded)
+        %T      seconds from midNight  (unpadded)
+    "
+
+    |dict hours minutes seconds usHours ampm s|
+
+    hours := self hours.
+    minutes := self minutes.
+    seconds := self seconds.
+
+    hours // 12 == 0 ifTrue:[
+        ampm := 'am'.
+    ] ifFalse:[
+        ampm := 'pm'.
+    ].
+    usHours := hours.
+    usHours ~~ 0 ifTrue:[
+        usHours := usHours - 1 \\ 12 + 1.
+    ].
+
+    dict := IdentityDictionary new.
+    dict at:$H put:(s := hours printString).
+    dict at:$h put:(s leftPaddedTo:2 with:$0).
+    dict at:$U put:(s := usHours printString).
+    dict at:$u put:(s leftPaddedTo:2 with:$0).
+    dict at:$M put:(s := minutes printString).
+    dict at:$m put:(s leftPaddedTo:2 with:$0).
+    dict at:$S put:(s := seconds printString).
+    dict at:$s put:(s leftPaddedTo:2 with:$0).
+    dict at:$t put:(seconds * minutes) printString.
+    dict at:$T put:(seconds * minutes * hours) printString.
+    dict at:$a put:ampm.
+    dict at:$A put:ampm asUppercase.
+
+    ^ (aFormatString expandPlaceholdersWith:dict)
+
+    "
+     Time now printStringFormat:'%U:%m:%s %a'   
+
+     Time now printStringFormat:'%h:%m:%s'     
+     Time now printStringFormat:'%H:%m:%s'      
+     Time now printStringFormat:'%u:%m:%s %a'   
+     Time now printStringFormat:'%h:%m'         
+     Time now printStringFormat:'%H:%m %A'     
+     Time now printStringFormat:'%m minutes after %U %a'     
+     Time now printStringFormat:'%t seconds after %U %a'     
+     Time now printStringFormat:'%T seconds from midNight'     
+    "
+
+    "Modified: 22.2.1996 / 16:58:30 / cg"
+! !
+
 !AbstractTime methodsFor:'private'!
 
 fromOSTime:osTime
@@ -455,5 +556,5 @@
 !AbstractTime class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.15 1998-05-22 10:47:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.16 1999-09-01 18:18:03 stefan Exp $'
 ! !
--- a/Time.st	Wed Sep 01 17:10:07 1999 +0200
+++ b/Time.st	Wed Sep 01 20:18:31 1999 +0200
@@ -474,37 +474,6 @@
     "Modified: 22.2.1996 / 16:58:30 / cg"
 !
 
-printOn:aStream format:aFormatString
-    "print using a format string;
-     valid format items are:
-        %h      hours, 00..23 (i.e. european)  0-padded to length 2
-        %u      hours, 00..12 (i.e. us)        0-padded to length 2
-        %m      minutes, 00..59                0-padded to length 2
-        %s      seconds, 00..59                0-padded to length 2
-        %a      am/pm
-
-     special:
-        %H      24-hours - unpadded
-        %U      12-hours - unpadded
-        %M      minutes - unpadded
-        %S      seconds - unpadded
-        %A      AM/PM   - uppercase
-    "
-
-    aStream nextPutAll:(self printStringFormat:aFormatString)
-
-    "
-     Time now printOn:Transcript format:'%h:%m:%s'   . Transcript cr.      
-     Time now printOn:Transcript format:'%H:%m:%s'   . Transcript cr.      
-     Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr.   
-     Time now printOn:Transcript format:'%h:%m'      . Transcript cr. 
-     Time now printOn:Transcript format:'%H:%m %A'   . Transcript cr.
-     Time now printOn:Transcript format:'minutes:%M seconds:%S'   . Transcript cr.
-    "
-
-    "Modified: 22.2.1996 / 16:58:30 / cg"
-!
-
 printString12HourFormat
     "return a printed representation in 12 hour format"
 
@@ -526,74 +495,6 @@
 
 !
 
-printStringFormat:aFormatString
-    "print using a format string;
-     valid format items are:
-        %h      hours, 00..23 (i.e. european)  0-padded to length 2
-        %u      hours, 00..12 (i.e. us)        0-padded to length 2
-        %m      minutes, 00..59                0-padded to length 2
-        %s      seconds, 00..59                0-padded to length 2
-        %a      am/pm
-
-     special:
-        %H      24-hours - unpadded
-        %U      12-hours - unpadded
-        %M      minutes - unpadded
-        %S      seconds - unpadded
-        %A      AM/PM   - uppercase
-
-        %t      seconds within hour  (unpadded)
-        %T      seconds from midNight  (unpadded)
-    "
-
-    |dict hours minutes seconds usHours ampm s|
-
-    hours := self hours.
-    minutes := self minutes.
-    seconds := self seconds.
-
-    hours // 12 == 0 ifTrue:[
-        ampm := 'am'.
-    ] ifFalse:[
-        ampm := 'pm'.
-    ].
-    usHours := hours.
-    usHours ~~ 0 ifTrue:[
-        usHours := usHours - 1 \\ 12 + 1.
-    ].
-
-    dict := IdentityDictionary new.
-    dict at:$H put:(s := hours printString).
-    dict at:$h put:(s leftPaddedTo:2 with:$0).
-    dict at:$U put:(s := usHours printString).
-    dict at:$u put:(s leftPaddedTo:2 with:$0).
-    dict at:$M put:(s := minutes printString).
-    dict at:$m put:(s leftPaddedTo:2 with:$0).
-    dict at:$S put:(s := seconds printString).
-    dict at:$s put:(s leftPaddedTo:2 with:$0).
-    dict at:$t put:(seconds * minutes) printString.
-    dict at:$T put:(seconds * minutes * hours) printString.
-    dict at:$a put:ampm.
-    dict at:$A put:ampm asUppercase.
-
-    ^ (aFormatString expandPlaceholdersWith:dict)
-
-    "
-     Time now printStringFormat:'%U:%m:%s %a'   
-
-     Time now printStringFormat:'%h:%m:%s'     
-     Time now printStringFormat:'%H:%m:%s'      
-     Time now printStringFormat:'%u:%m:%s %a'   
-     Time now printStringFormat:'%h:%m'         
-     Time now printStringFormat:'%H:%m %A'     
-     Time now printStringFormat:'%m minutes after %U %a'     
-     Time now printStringFormat:'%t seconds after %U %a'     
-     Time now printStringFormat:'%T seconds from midNight'     
-    "
-
-    "Modified: 22.2.1996 / 16:58:30 / cg"
-!
-
 shortPrintString
     "dummy - for now"
 
@@ -668,5 +569,5 @@
 !Time class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.41 1999-07-19 19:09:50 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.42 1999-09-01 18:18:31 stefan Exp $'
 ! !