UnixOperatingSystem.st
changeset 8823 2dcb60da6bcc
parent 8788 562f4f8bb3ed
child 8871 ad36cffaa66c
--- a/UnixOperatingSystem.st	Tue Apr 05 14:09:53 2005 +0200
+++ b/UnixOperatingSystem.st	Tue Apr 05 14:12:21 2005 +0200
@@ -8065,24 +8065,26 @@
     if (__bothSmallInteger(y, m)
      && __bothSmallInteger(d, h)
      && __bothSmallInteger(min, s)) {
-	tm.tm_hour = __intVal(h);
-	tm.tm_min = __intVal(min);
-	tm.tm_sec = __intVal(s);
-
-	tm.tm_year = __intVal(y) - 1900;
-	tm.tm_mon = __intVal(m) - 1;
-	tm.tm_mday = __intVal(d);
-	tm.tm_isdst = -1;
-
-	t = mktime(&tm);
-	if (utcBoolean == true) {
-	    t += TIMEZONE(&tm);
-	}
-	osSeconds = __MKUINT((INT)t);
+        tm.tm_hour = __intVal(h);
+        tm.tm_min = __intVal(min);
+        tm.tm_sec = __intVal(s);
+
+        tm.tm_year = __intVal(y) - 1900;
+        tm.tm_mon = __intVal(m) - 1;
+        tm.tm_mday = __intVal(d);
+        tm.tm_isdst = -1;
+
+        t = mktime(&tm);                        /* mktime() interprets tm as localtime */
+        if ((INT)t != -1) {
+            if (utcBoolean == true) {           /* convert to utc time */
+                t = (INT)t - TIMEZONE(&tm);     /* TIMZONE = seconds westward from 0 */
+            }
+            osSeconds = __MKINT((INT)t);        /* be careful, t can be negative at the start of the epoch ! */
+        }
     }
 %}.
     osSeconds notNil ifTrue:[
-	^ osSeconds * 1000 + millis
+        ^ osSeconds * 1000 + millis
     ].
     ^ self primitiveFailed
 
@@ -12299,7 +12301,7 @@
 !UnixOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.224 2005-03-15 16:05:26 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.225 2005-04-05 12:12:21 stefan Exp $'
 ! !
 
 UnixOperatingSystem initialize!