- Written and documented by David Deley


1:     2:     3:     4:     5:     6:     7:     8:     9:     10:     11:     12.1:     12.2:     12.3:     12.4:    

Introduction to CMac Chapter 8: 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.

NOTE: 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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemtime.asp

Code:
#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) );
}

1:     2:     3:     4:     5:     6:     7:     8:     9:     10:     11:     12.1:     12.2:     12.3:     12.4: