Introduction to CMac: 08. GetSystemTime

Multi-Edit CMac has the ability to call external routines provided by the Windows operating system. Here is an example of calling the GetSystemTime routine.

GetSystemTime returns Coordinated Universal Time (UTC). It does not take into account what time zone you are in. (i.e. UTC time is 5 hours ahead of Eastern Time; 8 hours ahead of Pacific Time.)

The GetSystemTime function is documented at this this MSDN article.

#include Win32.sh   //Must come before #include MsgLog.sh
                    //(defines struct Tmsg used by MsgLog.sh)
#include MsgLog.sh  //DebugLog is defined here.
 
/* NOTE: Win32.sh already contains the following,
   so we don't have to include this ourselves:
#define PSystemTime Pointer
 
struct TSystemTime {
  Word  wYear;
  Word  wMonth;
  Word  wDayOfWeek;
  Word  wDay;
  Word  wHour;
  Word  wMinute;
  Word  wSecond;
  Word  wMilliseconds;
}
 
import void GetSystemTime( PSystemTime St )
    kernel32 'GetSystemTime';
*/
 
void testtime()
{
   struct TSystemTime St;
   GetSystemTime( &St );
   DebugLog(2, "testtime",
  "wYear=" + str(St.wYear) +
  " wMonth=" + str(St.wMonth) +
  " wDayOfWeek=" + str(St.wDayOfWeek) +
  " wDay=" + str(St.wDay) +
  " wHour=" + str(St.wHour) +
  " wMinute=" + str(St.wMinute) +
  " wSecond=" + str(St.wSecond) +
  " wMilliseconds=" + str(St.wMilliseconds) );
}
 
doc/tutorial/cmac_8.txt · Last modified: 2009/03/18 10:18 by geofff     Back to top