A Mini API for date and time.
extern lib "kernel32.dll"
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME;
void GetSystemTime(SYSTEMTIME*t);
void GetLocalTime(SYSTEMTIME*t);
end extern
SYSTEMTIME t
'GetSystemTime t 'GMT (Greenwich Mean Time)
GetLocalTime t
String WeekDay[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}
String MonthName[12]={"January","February","March","April","May","June","July","August","September","October","November","December"}
String month=str t.wMonth : if len(month)<2 then month="0"+month
String day=str t.wDay : if len(day)<2 then day="0"+day
'
print "" t.wYear "-" month "-" day
print WeekDay[t.wDayOfWeek+1 and 7 ] " " MonthName[t.wMonth and 31] " " t.wDay " " t.wYear
There is a glitch have to fix on word (2 byte) members. They can be corrupted by higher bits, so I have used 'and' bit masks here in the critical places.
http://rosettacode.org/wiki/Date_format#OxygenBasichttp://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspxCharles