?date_Format(date()) *-------------------------------------------------------------------------- function Date_Format(d) #define DATE_SHORTDATE 0x00000001 #define DATE_LONGDATE 0x00000002 #define LOCALE_SYSTEM_DEFAULT 0x00000800 #define LOCALE_USER_DEFAULT 0x00000400 * LCID GetThreadLocale(void) declare long GetThreadLocale in win32api *int GetDateFormat( * LCID Locale, // locale * DWORD dwFlags, // options * CONST SYSTEMTIME *lpDate, // date * LPCTSTR lpFormat, // date format * LPTSTR lpDateStr, // formatted string buffer * int cchDate // size of buffer *); declare integer GetDateFormat in win32api ; long Locale, ; long dwFlags, ; string@ lpDate, ; String@ lpFormat, ; string@ lpDateStr, ; integer cchDate local lpDate, lpFormat, DateFormatted, nchars lpDate = SystemTimeStruct(d) DateFormatted = space(128) do case case !inlist(vartype(d), T_DATE, T_DATETIME ) assert FALSE return '' endcase lpFormat = [ddd', 'dd MMM yyyy] nchars = GetDateFormat( GetThreadLocale(), 0, @lpDate, @lpFormat, @DateFormatted, len(DateFormatted)) do case case empty(nchars) return '' case inlist(vartype(d), T_DATE) return left(DateFormatted, nchars-1) case inlist(vartype(d), T_DATETIME ) return left(DateFormatted, nchars-1) + ' ' + ttoc(d,2) endcase endfunc *--------------------------------------------------------------------------- function SystemTimeStruct(d) local s do case case inlist(vartype(d), T_DATE, T_DATETIME ) s = BinToWord(year(d)) ; + BinToWord(Month(d)) ; + BinToWord(mod(dow(d,2),7)) ; + BinToWord(day(d)) ; + BinToWord(hour(d)) ; + BinToWord(minute(d)) ; + BinToWord(sec(d)) ; + BinToWord(0) case vartype(d) == 'X' && null s = BinToWord(0) ; + BinToWord(0) ; + BinToWord(0) ; + BinToWord(0) ; + BinToWord(0) ; + BinToWord(0) ; + BinToWord(0) ; + BinToWord(0) otherwise assert FALSE s = '' endcase return s endfunc *--------------------------------------------------------------------------- function BinToWord(x) x = int(x) return chr(bitand(x, 0xff)) + ; chr(bitand(bitrshift(x, 8), 0xff)) endfunc *----------------------------------------------------------------------------