UnixOperatingSystem.st
changeset 6375 7391258a73e8
parent 6372 9cd3ac764491
child 6421 58dca33cf0fc
equal deleted inserted replaced
6374:fad888313ce3 6375:7391258a73e8
  8340 
  8340 
  8341 computeOSTimeFromUTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis
  8341 computeOSTimeFromUTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis
  8342     "return the OS-dependent time for the given time and day. 
  8342     "return the OS-dependent time for the given time and day. 
  8343      The arguments are assumed to be in UTC Time"
  8343      The arguments are assumed to be in UTC Time"
  8344 
  8344 
  8345     |osSeconds|
  8345     ^ self
  8346 
  8346         computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis utc:true
  8347 %{
       
  8348     struct tm tm;
       
  8349     TIME_T t;
       
  8350 
       
  8351     if (__bothSmallInteger(y, m) 
       
  8352      && __bothSmallInteger(d, h)
       
  8353      && __bothSmallInteger(min, s)) {
       
  8354 	tm.tm_hour = __intVal(h);
       
  8355 	tm.tm_min = __intVal(min);
       
  8356 	tm.tm_sec = __intVal(s);
       
  8357 
       
  8358 	tm.tm_year = __intVal(y) - 1900;
       
  8359 	tm.tm_mon = __intVal(m) - 1;
       
  8360 	tm.tm_mday = __intVal(d);
       
  8361 	tm.tm_isdst = -1;
       
  8362 
       
  8363 	t = mktime(&tm);
       
  8364 	osSeconds = __MKUINT((INT)t+TIMEZONE(&tm));
       
  8365     }
       
  8366 %}.
       
  8367     osSeconds notNil ifTrue:[
       
  8368 	^ osSeconds * 1000 + millis
       
  8369     ].    
       
  8370     ^ self primitiveFailed
       
  8371 
  8347 
  8372     "
  8348     "
  8373      OperatingSystem computeOSTimeFromUTCYear:1970 month:1 day:1 hour:0 minute:0 second:0 millisecond:0
  8349      OperatingSystem computeOSTimeFromUTCYear:1970 month:1 day:1 hour:0 minute:0 second:0 millisecond:0
  8374      OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
  8350      OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
  8375      OperatingSystem computeOSTimeFromUTCYear:2000 month:7 day:1 hour:0 minute:0 second:0 millisecond:0
  8351      OperatingSystem computeOSTimeFromUTCYear:2000 month:7 day:1 hour:0 minute:0 second:0 millisecond:0
  8380 computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis
  8356 computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis
  8381     "return the OS-dependent time for the given time and day. 
  8357     "return the OS-dependent time for the given time and day. 
  8382      The arguments are assumed to be in localtime including
  8358      The arguments are assumed to be in localtime including
  8383      any daylight saving adjustings."
  8359      any daylight saving adjustings."
  8384 
  8360 
       
  8361     ^ self
       
  8362         computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis utc:false
       
  8363     "
       
  8364      OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
       
  8365     "
       
  8366 !
       
  8367 
       
  8368 computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis utc:utcBoolean
       
  8369     "return the OS-dependent time for the given time and day. 
       
  8370      If utcBoolean is true, the arguments are assumed to be in UTC;
       
  8371      otherwise, in localtime including any daylight saving adjustings."
       
  8372 
  8385     |osSeconds|
  8373     |osSeconds|
  8386 
  8374 
  8387 %{
  8375 %{
  8388     struct tm tm;
  8376     struct tm tm;
  8389     TIME_T t;
  8377     TIME_T t;
  8390 
  8378 
  8391     if (__bothSmallInteger(y, m) 
  8379     if (__bothSmallInteger(y, m) 
  8392      && __bothSmallInteger(d, h)
  8380      && __bothSmallInteger(d, h)
  8393      && __bothSmallInteger(min, s)) {
  8381      && __bothSmallInteger(min, s)) {
  8394 	tm.tm_hour = __intVal(h);
  8382         tm.tm_hour = __intVal(h);
  8395 	tm.tm_min = __intVal(min);
  8383         tm.tm_min = __intVal(min);
  8396 	tm.tm_sec = __intVal(s);
  8384         tm.tm_sec = __intVal(s);
  8397 
  8385 
  8398 	tm.tm_year = __intVal(y) - 1900;
  8386         tm.tm_year = __intVal(y) - 1900;
  8399 	tm.tm_mon = __intVal(m) - 1;
  8387         tm.tm_mon = __intVal(m) - 1;
  8400 	tm.tm_mday = __intVal(d);
  8388         tm.tm_mday = __intVal(d);
  8401 	tm.tm_isdst = -1;
  8389         tm.tm_isdst = -1;
  8402 
  8390 
  8403 	t = mktime(&tm);
  8391         t = mktime(&tm);
  8404 	osSeconds = __MKUINT((INT)t);
  8392         if (utcBoolean == true) {
       
  8393             t += TIMEZONE(&tm);
       
  8394         }
       
  8395         osSeconds = __MKUINT((INT)t);
  8405     }
  8396     }
  8406 %}.
  8397 %}.
  8407     osSeconds notNil ifTrue:[
  8398     osSeconds notNil ifTrue:[
  8408 	^ osSeconds * 1000 + millis
  8399         ^ osSeconds * 1000 + millis
  8409     ].    
  8400     ].    
  8410     ^ self primitiveFailed
  8401     ^ self primitiveFailed
  8411 
  8402 
  8412     "
  8403     "
  8413      OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
  8404      OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0 utc:true  
  8414     "
  8405      OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0 utc:false  
  8415 
  8406     "
  8416 !
  8407 !
  8417 
  8408 
  8418 computeTimeAndDateFrom:osTime
  8409 computeTimeAndDateFrom:osTime
  8419     "given an OS-dependent time in osTime, return an Array
  8410     "given an OS-dependent time in osTime, return an Array
  8420      containing (full-) year, month, day, hour, minute and seconds,
  8411      containing (full-) year, month, day, hour, minute and seconds,
 10406 ! !
 10397 ! !
 10407 
 10398 
 10408 !UnixOperatingSystem::FilePointerHandle class methodsFor:'documentation'!
 10399 !UnixOperatingSystem::FilePointerHandle class methodsFor:'documentation'!
 10409 
 10400 
 10410 version
 10401 version
 10411     ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.114 2002-02-01 10:14:19 cg Exp $'
 10402     ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.115 2002-02-04 10:34:56 cg Exp $'
 10412 ! !
 10403 ! !
 10413 
 10404 
 10414 !UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
 10405 !UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
 10415 
 10406 
 10416 closeFile
 10407 closeFile
 12026 ! !
 12017 ! !
 12027 
 12018 
 12028 !UnixOperatingSystem class methodsFor:'documentation'!
 12019 !UnixOperatingSystem class methodsFor:'documentation'!
 12029 
 12020 
 12030 version
 12021 version
 12031     ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.114 2002-02-01 10:14:19 cg Exp $'
 12022     ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.115 2002-02-04 10:34:56 cg Exp $'
 12032 ! !
 12023 ! !
 12033 UnixOperatingSystem initialize!
 12024 UnixOperatingSystem initialize!