Author Topic: System Time  (Read 1652 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
System Time
« on: April 25, 2014, 05:47:21 PM »
Expressing Universal Coordinated Time, including milliseconds

2014.04.26 01:44.30.025

Note the short-form functions to format the values:
Code: [Select]
'http://msdn.microsoft.com/en-us/library/windows/desktop/ms724390(v=vs.85).aspx

type SYSTEMTIME word wYear,wMonth,wDayOfWeek,wDay, wHour,wMinute,wSecond,wMilliseconds

sys GetSystemTime lib "kernel32.dll" (SYSTEMTIME*lpSystemTime)

SYSTEMTIME t : GetSystemTime t

string f(word v) {return mid "0"+v , -2}
string m(word v) {return mid "00"+v, -3}

print _
t.wYear "." f(t.wMonth) "." f(t.wDay) " " +
f(t.wHour) ":" f(t.wMinute) ":" f(t.wSecond) +
"." m(t.wMilliseconds)

string f(word v) {return mid "0"+v , -2}
string m(word v) {return mid "00"+v, -3}

these function can be made even shorter:

string f(word v) = mid "0"+v , -2
string m(word v) = mid "00"+v, -3


or macros can be used instead:

macro f(v) mid( "0"+v , -2)
macro m(v) mid("00"+v, -3)
« Last Edit: April 25, 2014, 05:56:26 PM by Charles Pegge »