Fix for utc botch when retrieving seconds since 1901
authorStefan Vogel <sv@exept.de>
Thu, 06 Jul 2006 17:49:51 +0200
changeset 9429 173bcd493d7c
parent 9428 a46275bc78e7
child 9430 919e0cb2257c
Fix for utc botch when retrieving seconds since 1901 (#primSecondsClock and dateAndTimeFromSeconds:) - Caused swiki to report conflicts when editing pages
AbstractTime.st
--- a/AbstractTime.st	Thu Jul 06 12:57:05 2006 +0200
+++ b/AbstractTime.st	Thu Jul 06 17:49:51 2006 +0200
@@ -173,26 +173,41 @@
 !AbstractTime class methodsFor:'Compatibility-Squeak'!
 
 dateAndTimeFromSeconds: secondCount
+    "set date and time from seconds since 1901-01-01 UTC"
+    |timestamp|
+
+"   
+    secondsBetween1901and1970 := 
+        ((Date day:1 month:1 year:1970) subtractDate:(Date day:1 month:1 year:1901))
+        *  (24 * 60 * 60)
+"
+
+    timestamp := Timestamp fromSeconds:secondCount-2177452800.
     ^ Array
-        with: (Date fromSeconds: secondCount)
-        with: (Time fromSeconds: secondCount \\ 86400)
+        with: (timestamp asDate)
+        with: (timestamp asTime)
 
     "
+     Timestamp dateAndTimeFromSeconds: (Time primSecondsClock) 
      Time dateAndTimeFromSeconds: (Time totalSeconds) 
      Date dateAndTimeFromSeconds: (Time totalSeconds)
     "
 !
 
 primSecondsClock
-    "returns the number of seconds since 1.1.1901"
+    "returns the number of seconds since 1.1.1901 UTC"
+
+    ^ Timestamp now utcSecondsSince1901
 
-    ^ self totalSeconds
+    "                                                 
+     Timestamp primSecondsClock 
+    "
 ! !
 
 !AbstractTime class methodsFor:'Compatibility-VW'!
 
 totalSeconds
-    "returns the number of seconds since 1.1.1901"
+    "returns the number of seconds since 1.1.1901 UTC"
 
     ^ Timestamp now utcSecondsSince1901
 ! !
@@ -1034,5 +1049,5 @@
 !AbstractTime class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.50 2004-09-22 14:42:22 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.51 2006-07-06 15:49:51 stefan Exp $'
 ! !