--- a/Time.st Thu Nov 16 19:10:15 1995 +0100
+++ b/Time.st Fri Nov 17 00:28:50 1995 +0100
@@ -36,7 +36,7 @@
!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.21 1995-11-11 15:27:59 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.22 1995-11-16 23:28:50 cg Exp $'
!
documentation
@@ -78,27 +78,29 @@
"
!
-readFrom:aStream onError:exceptionBlock
+readFrom:aStringOrStream onError:exceptionBlock
"return a new Time, reading a printed representation from aStream.
If no pm follows the time, the string is interpreted as either 24 hour format
or being am."
- |hour min sec ex|
+ |str hour min sec ex|
+
+ str := aStringOrStream readStream.
ex := [^ exceptionBlock value].
- hour := Integer readFrom:aStream onError:ex.
+ hour := Integer readFrom:str onError:ex.
(hour between:0 and:24) ifFalse:[ex value].
- [aStream peek isDigit] whileFalse:[aStream next].
- min := Integer readFrom:aStream onError:ex.
+ [str peek isDigit] whileFalse:[str next].
+ min := Integer readFrom:str onError:ex.
(min between:0 and:59) ifFalse:[ex value].
- [aStream peek isDigit] whileFalse:[aStream next].
- sec := Integer readFrom:aStream onError:ex.
+ [str peek isDigit] whileFalse:[str next].
+ sec := Integer readFrom:str onError:ex.
(sec between:0 and:59) ifFalse:[ex value].
- [aStream peek == Character space] whileTrue:[aStream next].
- (aStream peek == $p) ifTrue:[
+ [str peek == Character space] whileTrue:[str next].
+ (str peek == $p) ifTrue:[
"pm"
hour := hour + 12
].
@@ -112,6 +114,8 @@
Time readFrom:'2:00:11 pm'
Time readFrom:'7:00:11 am'
"
+
+ "Modified: 16.11.1995 / 22:51:20 / cg"
! !
!Time methodsFor:'accessing'!