Win32OperatingSystem.st
changeset 11129 632cbbbaf162
parent 11092 a05bd545f00d
child 11135 db5762c9d81b
--- a/Win32OperatingSystem.st	Wed Aug 06 12:22:54 2008 +0200
+++ b/Win32OperatingSystem.st	Wed Aug 06 12:23:11 2008 +0200
@@ -725,7 +725,6 @@
     "Modified: 7.1.1997 / 19:36:11 / stefan"
 ! !
 
-
 !Win32OperatingSystem class methodsFor:'OS signal constants'!
 
 sigABRT
@@ -9535,7 +9534,7 @@
      An internal helper"
 
     |year month day hours minutes seconds utcOffset
-     dst yDay wDay info|
+     dst yDay wDay info reason|
 
 %{
     struct tm *tmPtr;
@@ -9547,64 +9546,77 @@
 
     /* try cache */
     {
-	OBJ lastSeconds, lastTimeInfo;
-
-	lastSeconds = @global(LastTimeInfoSeconds);
-	if (lastSeconds
-	 && (__longIntVal(lastSeconds) == t)
-	 && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
-	 && (@global(LastTimeInfoIsLocal) == isLocalTime)
-	) {
-	    lastTimeInfo = @global(LastTimeInfo);
-	    if (lastTimeInfo != nil) {
-		RETURN (lastTimeInfo);
-	    }
-	}
+        OBJ lastSeconds, lastTimeInfo;
+
+        lastSeconds = @global(LastTimeInfoSeconds);
+        if (lastSeconds
+         && (__longIntVal(lastSeconds) == t)
+         && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
+         && (@global(LastTimeInfoIsLocal) == isLocalTime)
+        ) {
+            lastTimeInfo = @global(LastTimeInfo);
+            if (lastTimeInfo != nil) {
+                RETURN (lastTimeInfo);
+            }
+        }
+    }
+    if (t == 0) {
+        reason = @symbol(invalidOSTime);
+        goto error;
     }
 
     tt = (time_t)t;
 
     if (isLocalTime == true) {
 #ifdef __BORLANDC__
-	tmPtr = localtime(&tt);
-#else
-	/* be thread safe */
-	if (localtime_s(&tmValue, &tt) == 0)
-	    tmPtr = &tmValue;
-	else
-	    tmPtr = NULL;
-#endif
-	if (tmPtr == NULL) goto error;
+        tmPtr = localtime(&tt);
+#else
+        /* be thread safe */
+        if (localtime_s(&tmValue, &tt) == 0)
+            tmPtr = &tmValue;
+        else
+            tmPtr = NULL;
+#endif
+        if (tmPtr == NULL) {
+            reason = @symbol(localtimeConversionFailed);
+            goto error;
+        }
 
 #ifdef WINDOWS_IS_POSIX_CONFORM_WHICH_IT_IS_NOT
-	utcOffset = __MKINT(tmPtr->tm_gmtoff);
-#else
-	{
-	    TIME_ZONE_INFORMATION tzInfo;
-	    int gmtoffMinutes = 0;
-
-	    if (GetTimeZoneInformation(&tzInfo) < 0) goto error;
-	    gmtoffMinutes = tzInfo.Bias;
-	    if (tmPtr->tm_isdst) {
-		gmtoffMinutes += tzInfo.DaylightBias;
-	    } else {
-		gmtoffMinutes += tzInfo.StandardBias;
-	    }
-	    utcOffset = __MKINT(gmtoffMinutes*60);
-	}
+        utcOffset = __MKINT(tmPtr->tm_gmtoff);
+#else
+        {
+            TIME_ZONE_INFORMATION tzInfo;
+            int gmtoffMinutes = 0;
+
+            if (GetTimeZoneInformation(&tzInfo) < 0) {
+                reason = @symbol(getTimeZoneFailed);
+                goto error;
+            }
+            gmtoffMinutes = tzInfo.Bias;
+            if (tmPtr->tm_isdst) {
+                gmtoffMinutes += tzInfo.DaylightBias;
+            } else {
+                gmtoffMinutes += tzInfo.StandardBias;
+            }
+            utcOffset = __MKINT(gmtoffMinutes*60);
+        }
 #endif
     } else {
 #ifdef __BORLANDC__
-	tmPtr = gmtime(&tt);
-#else
-	/* be thread safe */
-	if (gmtime_s(&tmValue, &tt) == 0)
-	    tmPtr = &tmValue;
-	else
-	    tmPtr = NULL;
-#endif
-	if (tmPtr == NULL) goto error;
-	utcOffset = __mkSmallInteger(0);
+        tmPtr = gmtime(&tt);
+#else
+        /* be thread safe */
+        if (gmtime_s(&tmValue, &tt) == 0)
+            tmPtr = &tmValue;
+        else
+            tmPtr = NULL;
+#endif
+        if (tmPtr == NULL) {
+            reason = @symbol(conversionToGMTimeFailed);
+            goto error;
+        }
+        utcOffset = __mkSmallInteger(0);
     }
 
     hours = __mkSmallInteger(tmPtr->tm_hour);
@@ -9622,22 +9634,22 @@
 error:;
 %}.
     dst isNil ifTrue:[
-	^ self primitiveFailed
+        ^ self primitiveFailed
     ].
 
     info := self timeInfoClass new.
     info
-	year:year
-	month:month
-	day:day
-	hours:hours
-	minutes:minutes
-	seconds:seconds
-	milliseconds:osMilliseconds
-	utcOffset:utcOffset
-	dst:dst
-	dayInYear:yDay
-	dayInWeek:wDay.
+        year:year
+        month:month
+        day:day
+        hours:hours
+        minutes:minutes
+        seconds:seconds
+        milliseconds:osMilliseconds
+        utcOffset:utcOffset
+        dst:dst
+        dayInYear:yDay
+        dayInWeek:wDay.
 
     LastTimeInfo := info.
     LastTimeInfoSeconds := osSeconds.
@@ -15601,7 +15613,7 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.340 2008-07-21 16:19:15 fm Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.341 2008-08-06 10:23:11 cg Exp $'
 ! !
 
 Win32OperatingSystem initialize!