Article ID: 188897
Article Last Modified on 7/30/1999
WORD wYear WORD wMonth WORD wDayOfWeek WORD wDay WORD wHour WORD wMinute WORD wSecond WORD wMillisecondsSimilar to all structures, you must construct a string containing its proper memory representation. The Word2Str function in the code below performs this conversion.
SET CENTURY ON
* Save the current date and time, reset it at the end.
m.olddate = DATE()
m.oldtime = TIME(1)
* Set the system time arbitrarily to 10:30:15 AM on 06/30/2001.
m.updtdate = {06/30/2001}
m.updttime = "10:30:15.00"
=setsystime(m.updtdate, m.updttime)
=MESSAGEBOX("Old date: " + DTOC(m.olddate) + CHR(13) + ;
"Old time: " + m.oldtime + CHR(13) + ;
"New system date: " + DTOC(DATE()) + CHR(13) + ;
"New system time: " + TIME(1), ;
0 + 64 + 0, ;
"SetLocalTime()")
* Now, reset it to its original value.
m.updtdate = m.olddate
m.updttime = m.oldtime
=setsystime(m.updtdate, m.updttime)
* Function setsystime.
* Parameters: date, character time in the form HH:MM:SS:hh.
* Returns: nothing.
FUNCTION setsystime
PARAMETERS m.updtdate, m.updttime
DECLARE SHORT SetLocalTime IN win32api STRING SystemTime
* Use SendMessage to tell everybody that we've changed the system time.
DECLARE INTEGER SendMessage IN win32api ;
INTEGER WindowHandle, ;
INTEGER MESSAGE, ;
STRING Param1, ;
STRING Param2
* SendMessage constants.
#DEFINE HWND_BROADCAST 65535
#DEFINE WM_TIMECHANGE 30
m.SystemTime = word2str(YEAR(m.updtdate)) + ;
word2str(MONTH(m.updtdate)) + ;
word2str(DOW(m.updtdate) - 1) + ;
word2str(DAY(m.updtdate)) + ;
word2str(VAL(LEFT(m.updttime, 2))) + ;
word2str(VAL(SUBSTR(m.updttime, 4, 2))) + ;
word2str(VAL(SUBSTR(m.updttime, 7, 2))) + ;
word2str(VAL(RIGHT(m.updttime, 2)))
m.retval = SetLocalTime(m.SystemTime)
* Send the message that the time has changed.
m.retval = SendMessage(HWND_BROADCAST, WM_TIMECHANGE, "", "")
* Function word2str.
* Parameters: 16-bit value.
* Returns: low-high format string for use in structures
* requiring a WORD value.
FUNCTION word2str
PARAMETERS m.wordval
PRIVATE i, m.retstr
m.retstr = ""
FOR i = 8 TO 0 STEP -8
m.retstr = CHR(INT(m.wordval/(2^i))) + m.retstr
m.wordval = MOD(m.wordval, (2^i))
NEXT
RETURN m.retstr
Additional query words: kbDSupport SYSTEMTIME SETLOCALTIME SETSYSTEMTIME time date kbDSE kbvfp500
Keywords: kbhowto KB188897