--- a/UnixOperatingSystem.st Sun Jul 02 14:49:01 2000 +0200
+++ b/UnixOperatingSystem.st Sun Jul 02 14:50:18 2000 +0200
@@ -7335,7 +7335,7 @@
and evaluate the argument, a 3-arg block with these.
Conversion is to localtime including any daylight saving adjustments."
- |year month day osSeconds|
+ |year month day osSeconds i|
osSeconds := osTime // 1000.
%{
@@ -7351,6 +7351,12 @@
month = __MKSMALLINT(tmPtr->tm_mon + 1);
day = __MKSMALLINT(tmPtr->tm_mday);
%}.
+ year isNil ifTrue:[
+ i := self computeTimeAndDateFrom:osTime.
+ year := i at:1.
+ month := i at:2.
+ day := i at:3.
+ ].
aBlock value:year value:month value:day
"
@@ -7443,61 +7449,17 @@
dayInYear (1..) and dayInWeek (1..).
Conversion is to localtime including any daylight saving adjustments."
- |low hi year month day hours minutes seconds millis utcOffset
- dst yDay wDay osSeconds ret|
+ |millis osSeconds ret|
millis := osTime \\ 1000.
osSeconds := osTime // 1000.
-%{
- struct tm *tmPtr;
- struct tm *gmTmPtr;
- INT t;
- TIME_T tt;
-
- t = __longIntVal(osSeconds);
- tt = (TIME_T)t;
-
- tmPtr = localtime(&tt);
- hours = __MKSMALLINT(tmPtr->tm_hour);
- minutes = __MKSMALLINT(tmPtr->tm_min);
- seconds = __MKSMALLINT(tmPtr->tm_sec);
-
- year = __MKSMALLINT(tmPtr->tm_year + 1900);
- month = __MKSMALLINT(tmPtr->tm_mon + 1);
- day = __MKSMALLINT(tmPtr->tm_mday);
-
- yDay = __MKSMALLINT(tmPtr->tm_yday+1);
- wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday);
-
- if (tmPtr->tm_isdst == 0) {
- dst = false;
- utcOffset = __MKINT(TIMEZONE(tmPtr));
- } else {
- dst = true;
-#ifdef HAS_ALTZONE
- utcOffset = __MKINT(altzone);
-#else
- utcOffset = __MKINT(TIMEZONE(tmPtr) + 3600);
-#endif
- }
-%}.
- "I would love to have SELF-like inline objects ..."
- ret := Array new:11.
- ret at:1 put:year.
- ret at:2 put:month.
- ret at:3 put:day.
- ret at:4 put:hours.
- ret at:5 put:minutes.
- ret at:6 put:seconds.
- ret at:7 put:utcOffset.
- ret at:8 put:dst.
+ ret := self fillTimeAndDateFromSeconds:osSeconds into:(Array new:11).
ret at:9 put:millis.
- ret at:10 put:yDay.
- ret at:11 put:wDay.
^ ret
"
OperatingSystem computeTimeAndDateFrom:0
+ OperatingSystem computeTimeAndDateFrom:1011
"
!
@@ -7506,7 +7468,7 @@
and evaluate the argument, a 4-arg block with these.
Conversion is to localtime including any daylight saving adjustments."
- |hours minutes seconds millis osSeconds|
+ |hours minutes seconds millis osSeconds i|
osSeconds := osTime // 1000.
millis := osTime \\ 1000.
@@ -7523,6 +7485,12 @@
minutes = __MKSMALLINT(tmPtr->tm_min);
seconds = __MKSMALLINT(tmPtr->tm_sec);
%}.
+ hours isNil ifTrue:[
+ i := self computeTimeAndDateFrom:osTime.
+ hours := i at:4.
+ minutes := i at:5.
+ seconds := i at:6.
+ ].
aBlock value:hours value:minutes value:seconds value:millis
"
@@ -7624,6 +7592,65 @@
"
!
+fillTimeAndDateFromSeconds:osSeconds into:timeArray
+ "fill the array with os-time components.
+ An internal helper"
+
+ |low hi year month day hours minutes seconds utcOffset
+ dst yDay wDay |
+
+%{
+ struct tm *tmPtr;
+ struct tm *gmTmPtr;
+ INT t;
+ TIME_T tt;
+
+ t = __longIntVal(osSeconds);
+ tt = (TIME_T)t;
+
+ tmPtr = localtime(&tt);
+ hours = __MKSMALLINT(tmPtr->tm_hour);
+ minutes = __MKSMALLINT(tmPtr->tm_min);
+ seconds = __MKSMALLINT(tmPtr->tm_sec);
+
+ year = __MKSMALLINT(tmPtr->tm_year + 1900);
+ month = __MKSMALLINT(tmPtr->tm_mon + 1);
+ day = __MKSMALLINT(tmPtr->tm_mday);
+
+ yDay = __MKSMALLINT(tmPtr->tm_yday+1);
+ wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday);
+
+ if (tmPtr->tm_isdst == 0) {
+ dst = false;
+ utcOffset = __MKINT(TIMEZONE(tmPtr));
+ } else {
+ dst = true;
+#ifdef HAS_ALTZONE
+ utcOffset = __MKINT(altzone);
+#else
+ utcOffset = __MKINT(TIMEZONE(tmPtr) + 3600);
+#endif
+ }
+%}.
+ "I would love to have SELF-like inline objects ..."
+ timeArray at:1 put:year.
+ timeArray at:2 put:month.
+ timeArray at:3 put:day.
+ timeArray at:4 put:hours.
+ timeArray at:5 put:minutes.
+ timeArray at:6 put:seconds.
+ timeArray at:7 put:utcOffset.
+ timeArray at:8 put:dst.
+ timeArray at:9 put:nil.
+ timeArray at:10 put:yDay.
+ timeArray at:11 put:wDay.
+ ^ timeArray
+
+ "
+ OperatingSystem fillTimeAndDateFromSeconds:0 into:(Array new:11)
+ "
+!
+
getMicrosecondTime
"This returns the microsecond timers value - if available.
On some machines, times with this precision may not be available,
@@ -7761,7 +7788,8 @@
#undef HAVE_TIME
RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) );
-%}
+%}.
+ self primitiveFailed
!
getOSTime
@@ -7910,7 +7938,7 @@
"cease ANY action for some time. This suspends the whole smalltalk
(unix-) process for some time if running threadless;
if running with threads (which is the default), this will
- only block until the nbext clock tick and return with the next
+ only block until the next clock tick and return with the next
timer interrupt.
Use either OperatingSystem>>millisecondDelay: (which makes all
threads sleep, but handles interrupts) or use a Delay (which makes
@@ -8911,6 +8939,6 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.82 2000-06-23 08:19:20 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.83 2000-07-02 12:50:18 cg Exp $'
! !
UnixOperatingSystem initialize!