#26 Format for DateTimePicker

open
5
2005-01-05
2005-01-05
Anonymous
No

How about a Format command for DateTimePicker
Proposed:
date->Format("%m/%d/%Y");
date->Format("%H:%M:%S");

#define maxTimeBufferSize 128
char *Format (LPTSTR lpszFormat)
{
SYSTEMTIME t;
if (GetSystemTime(&t) ==
GDT_VALID) { // convert to tm
struct tm tm1;
tm1.tm_sec = (int)
t.wSecond;
tm1.tm_min = (int)
t.wMinute;
tm1.tm_hour = (int)
t.wHour;
tm1.tm_mday = (int)
t.wDay;
tm1.tm_mon = (int)
t.wMonth - 1;
tm1.tm_year = (int)
t.wYear - 1900;
static char szBuffer
[maxTimeBufferSize];
if (!_tcsftime(szBuffer,
maxTimeBufferSize, lpszFormat, &tm1))
szBuffer[0] = '\0';
return szBuffer;
}
return NULL;
}

peter@howudodat.com

Discussion

    • assigned_to: nobody --> nenadstefanovic