class: Timestamp
authorca
Thu, 13 Nov 2014 13:54:05 +0100
changeset 17049 6ddd0b99a693
parent 17048 89053971191b
child 17050 f421040c58ae
class: Timestamp added: #printIso8601FormatOn:timeSeparator: #storeStringClass changed: #printIso8601FormatOn: #storeOn: (send #storeStringClass instead of #class) define seperator used by printIso8601FormatOn. storeString hook
Timestamp.st
--- a/Timestamp.st	Thu Nov 13 12:28:50 2014 +0100
+++ b/Timestamp.st	Thu Nov 13 13:54:05 2014 +0100
@@ -2546,9 +2546,30 @@
 printIso8601FormatOn:aStream
     "append the iso8601 representation of the receiver to aStream.
      This format looks like:
-	1999-01-01T24:00:00
+        1999-01-01T24:00:00
      or, for zero hr:min:sec,
-	1999-01-01
+        1999-01-01
+     Of course, a 24 hour clock is used.
+
+     Timezone information (eg. Z or +0100) is added, so the reader will read as local time."
+
+    self printIso8601FormatOn:aStream timeSeparator:$T
+
+    "
+     Timestamp now printIso8601FormatOn:Transcript. Transcript cr.
+     Timestamp readIso8601FormatFrom:(Timestamp now printStringIso8601Format).
+
+     UtcTimestamp now printIso8601FormatOn:Transcript. Transcript cr.
+     UtcTimestamp readIso8601FormatFrom:(UtcTimestamp now printStringIso8601Format).
+    "
+!
+
+printIso8601FormatOn:aStream timeSeparator:sepChar
+    "append the iso8601 representation of the receiver to aStream.
+     This format looks like:
+        1999-01-01T24:00:00
+     or, for zero hr:min:sec,
+        1999-01-01
      Of course, a 24 hour clock is used.
 
      Timezone information (eg. Z or +0100) is added, so the reader will read as local time."
@@ -2556,20 +2577,20 @@
     |asUTC asLocal|
 
     self isUtcTimestamp ifTrue:[
-	asUTC := true. asLocal := false.
+        asUTC := true. asLocal := false.
     ] ifFalse:[
-	self isLocalTimestamp ifTrue:[
-	    asUTC := false. asLocal := false.
-	] ifFalse:[
-	    asUTC := false. asLocal := false.
-	]
+        self isLocalTimestamp ifTrue:[
+            asUTC := false. asLocal := false.
+        ] ifFalse:[
+            asUTC := false. asLocal := false.
+        ]
     ].
 
     Timestamp::TimestampISO8601Builder
-	print:self compact:false
-	asLocal:asLocal asUTC:asUTC withMilliseconds:true
-	timeSeparator:$T
-	on:aStream
+        print:self compact:false
+        asLocal:asLocal asUTC:asUTC withMilliseconds:true
+        timeSeparator:sepChar
+        on:aStream
 
 "/
 "/    |format|
@@ -2773,8 +2794,8 @@
      Use a OS/architecture independent format"
 
     aStream nextPut:$(;
-	    nextPutAll:self class name;
-	    nextPutAll:' readIso8601FormatFrom:'''.
+            nextPutAll:self storeStringClass name;
+            nextPutAll:' readIso8601FormatFrom:'''.
     self printIso8601FormatOn:aStream.
     aStream nextPutAll:''')'.
 
@@ -2784,6 +2805,10 @@
      Object readFrom:(Timestamp now storeString) readStream
      Timestamp readFrom:(Timestamp now storeString) readStream
     "
+!
+
+storeStringClass
+    ^ self class
 ! !
 
 !Timestamp methodsFor:'private'!
@@ -3888,11 +3913,11 @@
 !Timestamp class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.201 2014-11-11 13:08:45 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.202 2014-11-13 12:54:05 ca Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.201 2014-11-11 13:08:45 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.202 2014-11-13 12:54:05 ca Exp $'
 ! !