Please enable JavaScript to view this site.

A-Shell Reference

Reviewed and Revised May 2024

xcall MIAMEX, MX_GETTIME, secs {,usecs, utcoffset}

MX_GETTIME (MIAMEX 75) returns the number of seconds, and optionally microseconds, since 00:00:00 January 1, 1970, Coordinated Universal Time (aka the "Epoch").

Parameters

secs  (Unsigned Integer, preferably B6)

will receive the number of seconds elapsed since the beginning of the "Epoch," midnight, Jan 1, 1970. See History note below.

usecs (Signed Num)

will be set to -1 if the feature is not supported (e.g. AIX, SCO) or else the number of microseconds to add to SECS. Note that under Windows, the actual resolution is only milliseconds, so USECS will always be a multiple of 1000. The microseconds value is probably not useful in itself but could be useful for measuring the amount of time that a very short operation takes (by calling MX_GETTIME twice, once before and once after). The sample program MIAMEX.BP in EXLIB:[908,30] has been updated to do just that, showing the time to execute a FOR/NEXT loop of 10000 iterations.

utcoffset (Signed Num)  [out]

Returns offset in seconds between local time and UTC (Universal Coordinated Time, aka Greenwich Mean Time). Offset will be negative for timezones West of Greenwich. A value of -1 indicates an error. Verions of A-Shell prior to 6.3.1518 will ignore the parameter; so unless you check the version, you should probably set your utcoffset value to -2 before calling the routine so that you can detect if it worked.

Comments

If you are using this function to measure an interval, keep in mind the possibility that the system clock might get updated during that interval, rendering your results meaningless.

The TIME system variable in ASB returns the number of seconds since midnight.

See Also

TIMESxs for a better way to measure precise intervals.
MX_FTFORMATxs to format the time.
TIME system variable

History

2023 August, A-Shell 6.5.1740:  Add support for additional timestamp bits (beyond 32) to resolve the Year 2038 problem. B6 was previously supported, for the secs parameter but the result was still limited to 32 bits.

2016 July, A-Shell 6.3.1518:  Add utcoffset parameter.