UtcTimestamp.st
branchjv
changeset 18120 e3a375d5f6a8
parent 18112 0d7ac9096619
parent 17130 de560263e67f
child 18457 214d760f8247
--- a/UtcTimestamp.st	Tue Feb 04 21:09:59 2014 +0100
+++ b/UtcTimestamp.st	Wed Apr 01 10:20:10 2015 +0100
@@ -45,6 +45,8 @@
 
     But when printing, accessing hour, minute, ... and converting to Date and Time,
     it returns the values represented in the UTC zone instead of the local timezone.
+    Be aware that this may lead to interesting results; for example when converting a timestamp
+    to a date, you may get a different date from an UTCTimestamp and a local timestamp.
 
     [author:]
         Stefan Vogel (stefan@zwerg.nil.exept.de)
@@ -62,11 +64,19 @@
 !UtcTimestamp methodsFor:'accessing'!
 
 timeInfo
-    ^ OperatingSystem computeUTCTimeAndDateFrom:osTime
+    ^ self utcTimeInfo
 !
 
 timeZoneName
-    ^ #utc
+    ^ 'UTC'
+!
+
+utcOffset
+    ^ 0
+!
+
+utcOffsetWithoutDst
+    ^ 0
 ! !
 
 !UtcTimestamp methodsFor:'converting'!
@@ -85,39 +95,57 @@
 
 !UtcTimestamp methodsFor:'initialization'!
 
-year:y month:m day:d hour:h minute:min second:s millisecond:millis 
-    osTime := OperatingSystem 
-                computeOSTimeFromUTCYear:y
-                month:m
-                day:d
-                hour:h
-                minute:min
-                second:s
-                millisecond:millis
+setOSTimeFromYear:y month:m day:d hour:h minute:min second:s millisecond:millis 
+    "private: ask the operating system to compute the internal osTime (based on the epoch),
+     given y,m,d and h,m,s in utc time"
+
+   self setOSTimeFromUTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis
 
     "
-     UtcTimestamp now   
-     Timestamp now      
+     UtcTimestamp now            
+     Timestamp now              
+     Timestamp now asTZTimestamp             
+     Timestamp now asUtcTimestamp  
     "
 
     "Modified (comment): / 13-10-2011 / 22:05:41 / cg"
 ! !
 
+!UtcTimestamp methodsFor:'private'!
+
+storeStringClass
+    ^ Timestamp
+! !
+
 !UtcTimestamp methodsFor:'testing'!
 
+isLocalTimestamp
+    "return true, if I am a local timestamp"
+
+    ^ false
+!
+
 isUtcTimestamp
+    "return true, if I am a utc timestamp"
+
     ^ true
 ! !
 
 !UtcTimestamp methodsFor:'visiting'!
 
 acceptVisitor:aVisitor with:aParameter
+    "dispatch for visitor pattern; send #visitUtcTimestamp:with: to aVisitor."
+
     ^ aVisitor visitUtcTimestamp:self with:aParameter
 ! !
 
 !UtcTimestamp class methodsFor:'documentation'!
 
+version
+    ^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.15 2014-11-26 09:32:11 cg Exp $'
+!
+
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.5 2013-11-25 14:50:54 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.15 2014-11-26 09:32:11 cg Exp $'
 ! !