Timestamp.st
branchjv
changeset 19945 9c7cd0ca7991
parent 19899 25b35b705da5
parent 19917 b273314a4ef7
child 19948 be658f466bca
--- a/Timestamp.st	Tue May 31 10:23:18 2016 +0100
+++ b/Timestamp.st	Wed Jun 01 14:11:19 2016 +0100
@@ -3132,15 +3132,15 @@
     utcOffset := (((hours * 60) + minutes) * 60).
 
     minutes isZero ifFalse: [
-	minute := minute + minutes.
-	minute >= 60 ifTrue: [
-	    hours := hours + 1.
-	    minute := minute - 60.
-	].
-	minute < 0 ifTrue: [
-	    hours := hours - 1.
-	    minute := minute + 60.
-	]
+        minute := minute + minutes.
+        minute >= 60 ifTrue: [
+            hours := hours + 1.
+            minute := minute - 60.
+        ].
+        minute < 0 ifTrue: [
+            hours := hours - 1.
+            minute := minute + 60.
+        ]
     ].
 
     "Hours may get zero by time zone specification or by minutes modifications above."
@@ -3149,24 +3149,24 @@
     "Add or subtract the hour and make date corrections if necessary."
     hour := hour + hours.
     hour < 0 ifTrue: [
-	"Oops, got to previous day, must adjust even the date."
-	hour := 24 - ((hour negated) \\ 24).
-	day := day - 1.
-	day <= 0 ifTrue: [
-	    "Got to previous month..."
-	    month := month - 1.
-	    month <= 0 ifTrue: [year := year - 1. month := 12].
-	    day := self lastDayInMonth: month
-	]
+        "Oops, got to previous day, must adjust even the date."
+        hour := 24 - ((hour negated) \\ 24).
+        day := day - 1.
+        day <= 0 ifTrue: [
+            "Go to previous month..."
+            month := month - 1.
+            month <= 0 ifTrue: [year := year - 1. month := 12].
+            day := self lastDayInMonth: month
+        ]
     ].
     hour >= 24 ifTrue: [
-	hour := hour \\ 24.
-	day := day + 1.
-	day > (self lastDayInMonth: month) ifTrue: [
-	    month := month + 1.
-	    month > 12 ifTrue: [year := year + 1. month := 1].
-	    day := 1
-	]
+        hour := hour \\ 24.
+        day := day + 1.
+        day > (self lastDayInMonth: month) ifTrue: [
+            month := month + 1.
+            month > 12 ifTrue: [year := year + 1. month := 1].
+            day := 1
+        ]
     ]
 
     "Created: / 15-06-2005 / 16:45:49 / masca"
@@ -3316,9 +3316,10 @@
     It covers the main features this builder has.
 
     Just to introduce some coding examples, try:
-	Timestamp readISO8601From: (TimestampISO8601Builder print: Timestamp now)
-	UtcTimestamp readISO8601From: (TimestampISO8601Builder print: UtcTimestamp now)
-	Timestamp readISO8601From: (TimestampISO8601Builder print: UtcTimestamp now)
+        Timestamp readISO8601From: (TimestampISO8601Builder print: Timestamp now)
+        UtcTimestamp readISO8601From: (TimestampISO8601Builder print: UtcTimestamp now)
+        Timestamp readISO8601From: (TimestampISO8601Builder print: UtcTimestamp now)
+        Timestamp readISO8601From: (TimestampISO8601Builder print: TZTimestamp now)
 
     Timestamp readISO8601From:'fooBar' onError:[ Timestamp now ].
 "
@@ -3912,7 +3913,7 @@
     If there is nothing more to read, the offset is unknown - this is treated as
     Zulu time as this may not be true."
 
-    | peek |
+    | peek tzOffset |
 
     peek := stream peek.
     peek ifNil: [^self].
@@ -3920,28 +3921,24 @@
 
     "If the time is in Zulu, don't modify the timestamp. This makes the machine
     run in Zulu time zone, maybe some corrections would be nice."
-    peek == $Z
-        ifTrue: [
-            "Time read, skip Zulu signature and exit."
-            isUtcTime := true.
-            stream next.
-            ^ self].
-
-    peek == $+
-        ifTrue: [
-            "Read a plus, expect a negative time zone difference."
-            hasTimezone := true.
-            stream next.
-            self addHoursAndMinutes: (self readTimezoneOffset collect: [:e | e negated]).
-            ^ self].
-
-    peek == $-
-        ifTrue: [
-            "Read a minus, expect positive time zone difference or unknown offset."
-            hasTimezone := true.
-            stream next.
-            self addHoursAndMinutes: self readTimezoneOffset.
-            ^ self].
+    peek == $Z ifTrue: [
+        "Time read, skip Zulu signature and exit."
+        isUtcTime := true.
+        stream next.
+        ^ self
+    ].
+
+    (peek == $+ or:[peek == $-]) ifTrue: [
+        "Read a plus/minus, expect a negative/positive time zone difference."
+        hasTimezone := true.
+        stream next.
+        tzOffset := self readTimezoneOffset.
+        peek == $+ ifTrue:[
+            tzOffset := tzOffset collect: [:e | e negated].
+        ].    
+        self addHoursAndMinutes: tzOffset.
+        ^ self
+    ].
 
     "This is local time"
     isUtcTime := false.