--- a/AbstractOperatingSystem.st Thu Nov 06 21:31:51 2014 +0100
+++ b/AbstractOperatingSystem.st Thu Nov 06 22:20:49 2014 +0100
@@ -604,36 +604,36 @@
"open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
This is typically used to present help-files, html documents, pdf documents etc.
operationSymbol is one of:
- open
- edit
- explore
- "
-
- self
- openApplicationForDocument:aFilenameOrString
- operation:operationSymbol
- mimeType:nil
+ open
+ edit
+ explore
+ "
+
+ self
+ openApplicationForDocument:aFilenameOrString
+ operation:operationSymbol
+ mimeType:nil
!
openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil
"open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
This is typically used to present help-files, html documents, pdf documents etc.
operationSymbol is one of:
- open
- edit
- explore
+ open
+ edit
+ explore
mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'.
If nil is passed in, the file's suffix is used to guess the mime type.
"
self
- openApplicationForDocument:aFilenameOrString
- operation:operationSymbol
- mimeType:mimeTypeStringArgOrNil
- ifNone:[
- "/ last resort: use a fileBrowser
- UserPreferences fileBrowserClass openOn:aFilenameOrString
- ].
+ openApplicationForDocument:aFilenameOrString
+ operation:operationSymbol
+ mimeType:mimeTypeStringArgOrNil
+ ifNone:[
+ "/ last resort: use a fileBrowser
+ UserPreferences fileBrowserClass openOn:aFilenameOrString
+ ].
"
self openApplicationForDocument: Filename currentDirectory operation:#open
@@ -650,9 +650,9 @@
"open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
This is typically used to present help-files, html documents, pdf documents etc.
operationSymbol is one of:
- open
- edit
- explore
+ open
+ edit
+ explore
mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf';
if nil is passed in, the file's suffix is used to guess it.
"
@@ -662,28 +662,28 @@
mimeTypeString := mimeTypeStringArgOrNil.
MIMETypes notNil ifTrue:[
- mimeTypeString isNil ifTrue:[
- mimeTypeString := MIMETypes mimeTypeForFilename:aFilenameOrString.
- ].
- mimeTypeString notNil ifTrue:[
- openCommand := MIMETypes defaultCommandTemplateToOpenMimeType:mimeTypeString.
- ].
+ mimeTypeString isNil ifTrue:[
+ mimeTypeString := MIMETypes mimeTypeForFilename:aFilenameOrString.
+ ].
+ mimeTypeString notNil ifTrue:[
+ openCommand := MIMETypes defaultCommandTemplateToOpenMimeType:mimeTypeString.
+ ].
].
openCommand notEmptyOrNil ifTrue:[
- (openCommand includesSubString:'%1') ifTrue:[
- openCommand := openCommand bindWith:aFilenameOrString asString.
- ] ifFalse:[
- openCommand := openCommand, ' "', aFilenameOrString asString, '"'.
- ].
-
- (self
- startProcess:openCommand
- inputFrom:nil outputTo:nil
- errorTo:nil auxFrom:nil
- environment:nil inDirectory:nil) notNil
- ifTrue:[
- ^ self.
- ].
+ (openCommand includesSubString:'%1') ifTrue:[
+ openCommand := openCommand bindWith:aFilenameOrString asString.
+ ] ifFalse:[
+ openCommand := openCommand, ' "', aFilenameOrString asString, '"'.
+ ].
+
+ (self
+ startProcess:openCommand
+ inputFrom:nil outputTo:nil
+ errorTo:nil auxFrom:nil
+ environment:nil inDirectory:nil) notNil
+ ifTrue:[
+ ^ self.
+ ].
].
exceptionBlock notNil ifTrue:[ exceptionBlock value ].
@@ -2699,16 +2699,16 @@
"return some object filled with info for the file 'aPathName';
the info (for which corresponding access methods are understood by
the returned object) is:
- type - a symbol giving the file's type
- mode - numeric access mode
- uid - owners user id
- gid - owners group id
- size - files size
- id - files number (i.e. inode number)
- accessed - last access time (as Timestamp)
- modified - last modification time (as Timestamp)
- statusChanged - last status change time (as Timestamp)
- alternativeName - (windows only: the MSDOS name of the file)
+ type - a symbol giving the file's type
+ mode - numeric access mode
+ uid - owners user id
+ gid - owners group id
+ size - files size
+ id - files number (i.e. inode number)
+ accessed - last access time (as Timestamp)
+ modified - last modification time (as Timestamp)
+ statusChanged - last status change time (as Timestamp)
+ alternativeName - (windows only: the MSDOS name of the file)
Some of the fields may be returned as nil on systems which do not provide
all of the information.
@@ -4197,11 +4197,11 @@
randomBytesInto:bufferOrInteger
"If bufferOrInteger is a String or a ByteArray,
- fill a given buffer with random bytes from the RtlGenRandom function
- and answer the buffer.
+ fill a given buffer with random bytes from the RtlGenRandom function
+ and answer the buffer.
If bufferOrInteger is a SmallInteger,
- return this many bytes (max 4) as a SmallInteger.
+ return this many bytes (max 4) as a SmallInteger.
Return nil on error (may raise PrimitiveFailure, too).
@@ -4396,44 +4396,44 @@
"/ accept the fact that sometimes, we cannot figure out, where I im
execPath := self pathOfSTXExecutable.
execPath notNil ifTrue:[
- "/
- "/ the executable's directory:
- "/ (/opt/stx/bin/stx -> /opt/stx/bin)
- "/
- appDir := execPath asFilename directory.
- (packagePath includes:appDir) ifFalse:[
- packagePath add:appDir.
- ].
-
- "/
- "/ the executable's parent directory:
- "/ (/opt/stx/bin/stx -> /opt/stx)
- "/
- appDir := appDir directory.
- dirName := appDir pathName.
- (packagePath includes:dirName) ifFalse:[
- packagePath add:dirName.
- ].
+ "/
+ "/ the executable's directory:
+ "/ (/opt/stx/bin/stx -> /opt/stx/bin)
+ "/
+ appDir := execPath asFilename directory.
+ (packagePath includes:appDir) ifFalse:[
+ packagePath add:appDir.
+ ].
+
+ "/
+ "/ the executable's parent directory:
+ "/ (/opt/stx/bin/stx -> /opt/stx)
+ "/
+ appDir := appDir directory.
+ dirName := appDir pathName.
+ (packagePath includes:dirName) ifFalse:[
+ packagePath add:dirName.
+ ].
].
homeDirName := OperatingSystem getHomeDirectory.
homeDirName notNil ifTrue:[
- "/
- "/ a users private smalltalk directory in its home (login) directory:
- "/ $HOME/.smalltalk/packages or $HOME\smalltalk\packages
- "/
- OperatingSystem isUNIXlike ifTrue:[
- priv := '.smalltalk'.
- ] ifFalse:[
- priv := 'smalltalk'.
- ].
- userPrivateSTXDir := homeDirName asFilename / priv.
- (userPrivateSTXDir isDirectory) ifTrue:[
- dirName := userPrivateSTXDir pathName.
- (packagePath includes:dirName) ifFalse:[
- packagePath add:dirName
- ]
- ].
+ "/
+ "/ a users private smalltalk directory in its home (login) directory:
+ "/ $HOME/.smalltalk/packages or $HOME\smalltalk\packages
+ "/
+ OperatingSystem isUNIXlike ifTrue:[
+ priv := '.smalltalk'.
+ ] ifFalse:[
+ priv := 'smalltalk'.
+ ].
+ userPrivateSTXDir := homeDirName asFilename / priv.
+ (userPrivateSTXDir isDirectory) ifTrue:[
+ dirName := userPrivateSTXDir pathName.
+ (packagePath includes:dirName) ifFalse:[
+ packagePath add:dirName
+ ]
+ ].
].
"/
@@ -4442,49 +4442,49 @@
"/
topDirName := OperatingSystem getEnvironment:'STX_TOPDIR'.
topDirName notNil ifTrue:[
- (packagePath includes:topDirName) ifFalse:[
- packagePath add:topDirName
- ].
+ (packagePath includes:topDirName) ifFalse:[
+ packagePath add:topDirName
+ ].
].
packagePath := packagePath select:[:each | (each asFilename / 'packages') exists]
- thenCollect:[:each | (each asFilename constructString:'packages')].
+ thenCollect:[:each | (each asFilename constructString:'packages')].
"
unconditionally prepend all directories from $STX_PACKAGEPATH
"
(dirName := OperatingSystem getEnvironment:'STX_PACKAGEPATH') notNil ifTrue:[
- dirName := dirName asCollectionOfSubstringsSeparatedBy:$:.
- dirName reverseDo:[:eachDirectoryName|
- (packagePath includes:eachDirectoryName) ifFalse:[
- packagePath addFirst:eachDirectoryName.
- ].
- ].
+ dirName := dirName asCollectionOfSubstringsSeparatedBy:$:.
+ dirName reverseDo:[:eachDirectoryName|
+ (packagePath includes:eachDirectoryName) ifFalse:[
+ packagePath addFirst:eachDirectoryName.
+ ].
+ ].
].
false ifTrue:[
appDir notNil ifTrue:[
- "maybe the sources are kept in a central place..."
- (appDir / 'source') isDirectory ifTrue:[
- packagePath add:(appDir / 'source') pathName.
- ].
+ "maybe the sources are kept in a central place..."
+ (appDir / 'source') isDirectory ifTrue:[
+ packagePath add:(appDir / 'source') pathName.
+ ].
].
].
"maybe we are running in the build environment: XXX/stx /projects /smalltalk
- or: XXX/exept /expecco /application
+ or: XXX/exept /expecco /application
- if XXX/stx/libbasic exists, add XXX to the package path"
false ifTrue:[
topDirName isNil ifTrue:[
- "appdir is now: projects"
- appDir := appDir directory directory.
- (appDir / 'stx' / 'libbasic') isDirectory ifTrue:[
- appDir pathName = homeDirName ifTrue:[
- "but take care, it may be directly in the home directory"
- appDir := appDir / 'stx'.
- ].
- packagePath add:appDir pathName.
- ].
+ "appdir is now: projects"
+ appDir := appDir directory directory.
+ (appDir / 'stx' / 'libbasic') isDirectory ifTrue:[
+ appDir pathName = homeDirName ifTrue:[
+ "but take care, it may be directly in the home directory"
+ appDir := appDir / 'stx'.
+ ].
+ packagePath add:appDir pathName.
+ ].
].
].
^ packagePath
@@ -4521,17 +4521,17 @@
"/
appPath := self pathOfSTXExecutable.
appPath notNil ifTrue:[
- appDir := appPath asFilename directory.
- appPath := appDir pathName.
- (sysPath includes:appPath) ifFalse:[
- sysPath add:appPath.
- ].
- appDir baseName = 'bin' ifTrue:[
- appPath := appDir directory pathName.
- (sysPath includes:appPath) ifFalse:[
- sysPath add:appPath.
- ].
- ].
+ appDir := appPath asFilename directory.
+ appPath := appDir pathName.
+ (sysPath includes:appPath) ifFalse:[
+ sysPath add:appPath.
+ ].
+ appDir baseName = 'bin' ifTrue:[
+ appPath := appDir directory pathName.
+ (sysPath includes:appPath) ifFalse:[
+ sysPath add:appPath.
+ ].
+ ].
].
"/
@@ -4539,45 +4539,45 @@
"/
homePath := self getHomeDirectory.
homePath notNil ifTrue:[
- "/
- "/ a users private smalltalk directory in its home (login) directory
- "/
- OperatingSystem isUNIXlike ifTrue:[
- priv := '.smalltalk'.
- ] ifFalse:[
- priv := 'smalltalk'.
- ].
- userPrivateSTXDir := homePath asFilename construct:priv.
- (userPrivateSTXDir isDirectory) ifTrue:[
- userPrivateSTXDir := userPrivateSTXDir pathName.
- (sysPath includes:userPrivateSTXDir) ifFalse:[
- sysPath add:userPrivateSTXDir
- ]
- ].
+ "/
+ "/ a users private smalltalk directory in its home (login) directory
+ "/
+ OperatingSystem isUNIXlike ifTrue:[
+ priv := '.smalltalk'.
+ ] ifFalse:[
+ priv := 'smalltalk'.
+ ].
+ userPrivateSTXDir := homePath asFilename construct:priv.
+ (userPrivateSTXDir isDirectory) ifTrue:[
+ userPrivateSTXDir := userPrivateSTXDir pathName.
+ (sysPath includes:userPrivateSTXDir) ifFalse:[
+ sysPath add:userPrivateSTXDir
+ ]
+ ].
].
"/
"/ SMALLTALK_LIBDIR, STX_LIBDIR and STX_TOPDIR from the environment
"/
#(
- 'SMALLTALK_LIBDIR'
- 'STX_LIBDIR'
- 'STX_TOPDIR'
+ 'SMALLTALK_LIBDIR'
+ 'STX_LIBDIR'
+ 'STX_TOPDIR'
) do:[:each |
- p := OperatingSystem decodePath:(OperatingSystem getEnvironment:each).
- p notNil ifTrue:[
- p := p asFilename pathName.
- (p asFilename isDirectory) ifTrue:[
- (sysPath includes:p) ifFalse:[
- sysPath add:p
- ]
- ]
- ].
+ p := OperatingSystem decodePath:(OperatingSystem getEnvironment:each).
+ p notNil ifTrue:[
+ p := p asFilename pathName.
+ (p asFilename isDirectory) ifTrue:[
+ (sysPath includes:p) ifFalse:[
+ sysPath add:p
+ ]
+ ]
+ ].
].
^ sysPath
"
- OperatingSystem defaultSystemPath
+ OperatingSystem defaultSystemPath
"
"Modified: / 24.12.1999 / 00:30:27 / cg"
@@ -5677,7 +5677,7 @@
"Created: / 13.7.1999 / 12:44:03 / stefan"
!
-computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis
+computeOSTimeFromYear:y month:m day:d hour:h minute:min second:s millisecond:millis
"return the OS-dependent time for the given time and day.
The arguments are assumed to be in localtime including
any daylight saving adjustings."
@@ -7519,11 +7519,11 @@
!AbstractOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.270 2014-11-06 14:52:46 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.271 2014-11-06 21:20:49 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.270 2014-11-06 14:52:46 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.271 2014-11-06 21:20:49 cg Exp $'
! !
--- a/UnixOperatingSystem.st Thu Nov 06 21:31:51 2014 +0100
+++ b/UnixOperatingSystem.st Thu Nov 06 22:20:49 2014 +0100
@@ -9199,7 +9199,7 @@
The arguments are assumed to be in UTC Time"
^ self
- computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis utc:true
+ computeOSTimeFromYear:y month:m day:d hour:h minute:min second:s millisecond:millis utc:true
"
OperatingSystem computeOSTimeFromUTCYear:1970 month:1 day:1 hour:0 minute:0 second:0 millisecond:0
@@ -9209,19 +9209,19 @@
"
!
-computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis
+computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millisecond:millis
"return the OS-dependent time for the given time and day.
The arguments are assumed to be in localtime including
any daylight saving adjustings."
^ self
- computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis utc:false
+ computeOSTimeFromYear:y month:m day:d hour:h minute:min second:s millisecond:millis utc:false
"
OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
"
!
-computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis utc:utcBoolean
+computeOSTimeFromYear:y month:m day:d hour:h minute:min second:s millisecond:millis utc:utcBoolean
"return the OS-dependent time for the given time and day.
If utcBoolean is true, the arguments are assumed to be in UTC;
otherwise, in localtime including any daylight saving adjustings."
@@ -9578,63 +9578,63 @@
tt = __signedLongIntVal(osSeconds);
if (tt == 0 && !__isSmallInteger(osSeconds))
- goto error;
+ goto error;
/* try cache */
{
- OBJ lastSeconds, lastTimeInfo;
-
- lastSeconds = @global(LastTimeInfoSeconds);
- if (lastSeconds
- && (__longIntVal(lastSeconds) == tt)
- && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
- && (@global(LastTimeInfoIsLocal) == isLocalTime)
- ) {
- lastTimeInfo = @global(LastTimeInfo);
- if (lastTimeInfo != nil) {
- RETURN (lastTimeInfo);
- }
- }
+ OBJ lastSeconds, lastTimeInfo;
+
+ lastSeconds = @global(LastTimeInfoSeconds);
+ if (lastSeconds
+ && (__longIntVal(lastSeconds) == tt)
+ && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
+ && (@global(LastTimeInfoIsLocal) == isLocalTime)
+ ) {
+ lastTimeInfo = @global(LastTimeInfo);
+ if (lastTimeInfo != nil) {
+ RETURN (lastTimeInfo);
+ }
+ }
}
if (isLocalTime == true) {
- result = localtime_r(&tt, &tmValue);
+ result = localtime_r(&tt, &tmValue);
} else {
- result = gmtime_r(&tt, &tmValue);
+ result = gmtime_r(&tt, &tmValue);
}
if (result != NULL) {
- hours = __mkSmallInteger(tmValue.tm_hour);
- minutes = __mkSmallInteger(tmValue.tm_min);
- seconds = __mkSmallInteger(tmValue.tm_sec);
-
- year = __mkSmallInteger(tmValue.tm_year + 1900);
- month = __mkSmallInteger(tmValue.tm_mon + 1);
- day = __mkSmallInteger(tmValue.tm_mday);
-
- yDay = __mkSmallInteger(tmValue.tm_yday+1);
- wDay = __mkSmallInteger(tmValue.tm_wday == 0 ? 7 : tmValue.tm_wday);
- utcOffset = __mkSmallInteger(TIMEZONE(&tmValue));
- dst = (tmValue.tm_isdst == 0 ? false : true);
+ hours = __mkSmallInteger(tmValue.tm_hour);
+ minutes = __mkSmallInteger(tmValue.tm_min);
+ seconds = __mkSmallInteger(tmValue.tm_sec);
+
+ year = __mkSmallInteger(tmValue.tm_year + 1900);
+ month = __mkSmallInteger(tmValue.tm_mon + 1);
+ day = __mkSmallInteger(tmValue.tm_mday);
+
+ yDay = __mkSmallInteger(tmValue.tm_yday+1);
+ wDay = __mkSmallInteger(tmValue.tm_wday == 0 ? 7 : tmValue.tm_wday);
+ utcOffset = __mkSmallInteger(TIMEZONE(&tmValue));
+ dst = (tmValue.tm_isdst == 0 ? false : true);
}
error:;
%}.
year isNil ifTrue:[
- TimeConversionError raiseErrorString:' - out of range'.
+ TimeConversionError raiseErrorString:' - out of range'.
].
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.
%{
@global(LastTimeInfo) = info; __GSTORE(info);
@@ -13516,11 +13516,11 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.385 2014-11-06 14:10:11 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.386 2014-11-06 21:20:49 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.385 2014-11-06 14:10:11 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.386 2014-11-06 21:20:49 cg Exp $'
! !
--- a/Win32OperatingSystem.st Thu Nov 06 21:31:51 2014 +0100
+++ b/Win32OperatingSystem.st Thu Nov 06 22:20:49 2014 +0100
@@ -16,7 +16,8 @@
AbstractOperatingSystem subclass:#Win32OperatingSystem
instanceVariableNames:''
- classVariableNames:'Initialized HostName DomainName CurrentDirectory'
+ classVariableNames:'Initialized HostName DomainName CurrentDirectory
+ LastOsTimeLow LastOsTimeHi LastTimeInfoIsLocal LastTimeInfo'
poolDictionaries:'Win32Constants'
category:'OS-Windows'
!
@@ -624,12 +625,15 @@
/*
* The difference between the Windows epoch (1601-01-01 00:00:00)
- * and the Unix epoch (1970-01-01 00:00:00) in milliseconds is: 11644473600000L
+ * and the Unix epoch (1970-01-01 00:00:00) in seconds is 11644470000 seconds.
+milliseconds is: 11644473600000L
+ 11644470000
+ * nov 2014: no longer rebias; return the value as is.
*/
void
TimetToFileTime( time_t t, LPFILETIME pft )
{
- LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000;
+ LONGLONG ll = Int32x32To64(t, 10000000) /* + 116444736000000000 */;
pft->dwLowDateTime = (DWORD) ll;
pft->dwHighDateTime = ll >>32;
}
@@ -638,11 +642,19 @@
FileTimeToOsTime(LPFILETIME pft)
{
LONGLONG lTime = ((LONGLONG)pft->dwHighDateTime << 32) + pft->dwLowDateTime;
- lTime = (lTime / 10000) - 11644473600000L;
+ // lTime = (lTime / 10000) - 11644473600000L;
return(__MKLARGEINT64(1, (unsigned INT)(lTime & 0xFFFFFFFF), (unsigned INT)(lTime >> 32)));
}
+void
+OsTimeToFileTime(OBJ tLow, OBJ tHigh, LPFILETIME pft) {
+ UINT low = __longIntVal(tLow);
+ UINT hi = __longIntVal(tHigh);
+
+ pft->dwHighDateTime = hi;
+ pft->dwLowDateTime = low;
+}
%}
! !
@@ -10135,6 +10147,12 @@
!Win32OperatingSystem class methodsFor:'time and date'!
+osTimeOf19700101
+ "the number of millis from 1.1.1601 to 1.1.1970"
+
+ ^ 116444736000000000
+!
+
computeOSTimeFromUTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis
"return the OS-dependent time for the given time and day.
The arguments are assumed to be in UTC time."
@@ -10175,7 +10193,7 @@
"Modified: / 07-07-2010 / 16:56:21 / cg"
!
-computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis
+computeOSTimeFromYear:y month:m day:d hour:h minute:min second:s millisecond:millis
"return the OS-dependent time for the given time and day.
The arguments are assumed to be in localtime including
any daylight saving adjustings."
@@ -10424,29 +10442,66 @@
"
!
-timeInfoFromSeconds:osSeconds milliseconds:osMilliseconds localTime:isLocalTime
- "return a timeInfo structure containing values for the given
- OS-second value.
+computeTimeAndDateFrom:osTime
+ "given an OS-dependent time in osTime, return an Array
+ containing (full-) year, month, day, hour, minute and seconds,
+ offset to UTC, daylight savings time flag, milliseconds,
+ dayInYear (1..) and dayInWeek (1..).
+ Conversion is to localtime including any daylight saving adjustments."
+
+ |ret|
+
+ ret := self timeInfoFromOsTime:osTime localTime:true.
+ ^ ret
+!
+
+computeUTCTimeAndDateFrom:osTime
+ "given an OS-dependent time in osTime, return an Array
+ containing:
+ (full-) year,
+ month, (1..)
+ day, (1..)
+ hour, (0..23)
+ minute (0..59)
+ seconds, (0..59)
+ offset to UTC, (seconds)
+ daylight savings time flag,
+ milliseconds, (0..999)
+ dayInYear (1..)
+ dayInWeek (1..).
+ Conversion is to utc."
+
+ |ret|
+
+ ret := self timeInfoFromOsTime:osTime localTime:false.
+ ^ ret
+!
+
+timeInfoFromOsTime:osTime localTime:isLocalTime
+ "return a timeInfo structure containing values for the given OS-second value.
An internal helper"
- |year month day hours minutes seconds utcOffset dstOffset
- dst yDay weekDay info reason|
+ |year month day hours minutes seconds millis utcOffset dstOffset
+ dst yDay weekDay info reason tLow tHigh|
+
+ tLow := osTime bitAnd:16rFFFFFFFF.
+ tHigh := osTime bitShift:-32.
%{
UINT t;
FILETIME fileTime, localFileTime;
SYSTEMTIME sysTime;
- t = __longIntVal(osSeconds);
-
/* try cache */
{
- OBJ lastSeconds, lastTimeInfo;
-
- lastSeconds = @global(LastTimeInfoSeconds);
- if (lastSeconds
- && (__longIntVal(lastSeconds) == t)
- && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
+ OBJ lastOsTimeLow, lastOsTimeHi, lastTimeInfo;
+
+ lastOsTimeLow = @global(LastOsTimeLow);
+ lastOsTimeHi = @global(LastOsTimeHi);
+ if (lastOsTimeLow
+ && (__longIntVal(lastOsTimeLow) == __longIntVal(tLow))
+ && lastOsTimeHi
+ && (__longIntVal(lastOsTimeHi) == __longIntVal(tHigh))
&& (@global(LastTimeInfoIsLocal) == isLocalTime)
) {
lastTimeInfo = @global(LastTimeInfo);
@@ -10456,7 +10511,10 @@
}
}
- TimetToFileTime((time_t)t, &fileTime);
+ OsTimeToFileTime(tLow, tHigh, &fileTime);
+
+ // t = __longIntVal(osSeconds);
+ // TimetToFileTime((time_t)t, &fileTime);
if (isLocalTime == true) {
TIME_ZONE_INFORMATION tzInfo;
@@ -10488,6 +10546,8 @@
month = __mkSmallInteger(sysTime.wMonth);
day = __mkSmallInteger(sysTime.wDay);
+ millis = __mkSmallInteger(sysTime.wMilliseconds);
+
weekDay = __mkSmallInteger(sysTime.wDayOfWeek == 0 ? 7 : sysTime.wDayOfWeek);
error:;
%}.
@@ -10503,15 +10563,15 @@
hours:hours
minutes:minutes
seconds:seconds
- milliseconds:osMilliseconds
+ milliseconds:millis
utcOffset:utcOffset
dst:(utcOffset = dstOffset)
dayInYear:yDay
dayInWeek:weekDay.
LastTimeInfo := info.
- LastTimeInfoSeconds := osSeconds.
- LastTimeInfoMilliseconds := osMilliseconds.
+ LastOsTimeLow := tLow.
+ LastOsTimeHi := tHigh.
LastTimeInfoIsLocal := isLocalTime.
^ info
@@ -17655,15 +17715,15 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.506 2014-11-06 20:31:51 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.507 2014-11-06 21:20:49 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.506 2014-11-06 20:31:51 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.507 2014-11-06 21:20:49 cg Exp $'
!
version_SVN
- ^ '$Id: Win32OperatingSystem.st,v 1.506 2014-11-06 20:31:51 cg Exp $'
+ ^ '$Id: Win32OperatingSystem.st,v 1.507 2014-11-06 21:20:49 cg Exp $'
! !