1c2c66affSColin Finck /*
2c2c66affSColin Finck * LOCALE.C - locale handling.
3c2c66affSColin Finck *
4c2c66affSColin Finck *
5c2c66affSColin Finck * History:
6c2c66affSColin Finck *
7c2c66affSColin Finck * 09-Jan-1999 (Eric Kohl)
8c2c66affSColin Finck * Started.
9c2c66affSColin Finck *
10c2c66affSColin Finck * 20-Jan-1999 (Eric Kohl)
11c2c66affSColin Finck * Unicode safe!
12c2c66affSColin Finck */
13c2c66affSColin Finck
14c2c66affSColin Finck #include "precomp.h"
15c2c66affSColin Finck
16c2c66affSColin Finck TCHAR cDateSeparator;
17c2c66affSColin Finck TCHAR cTimeSeparator;
18c2c66affSColin Finck TCHAR cThousandSeparator;
19c2c66affSColin Finck TCHAR cDecimalSeparator;
20c2c66affSColin Finck INT nDateFormat;
21c2c66affSColin Finck INT nTimeFormat;
22c2c66affSColin Finck INT nNumberGroups;
23c2c66affSColin Finck
24c2c66affSColin Finck
InitLocale(VOID)25c2c66affSColin Finck VOID InitLocale(VOID)
26c2c66affSColin Finck {
27c2c66affSColin Finck TCHAR szBuffer[256];
28c2c66affSColin Finck
29c2c66affSColin Finck /* date settings */
30c2c66affSColin Finck GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDATE, szBuffer, ARRAYSIZE(szBuffer));
31c2c66affSColin Finck cDateSeparator = szBuffer[0];
32c2c66affSColin Finck GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDATE | LOCALE_RETURN_NUMBER, (LPTSTR)&nDateFormat, sizeof(nDateFormat) / sizeof(TCHAR));
33c2c66affSColin Finck
34c2c66affSColin Finck /* time settings */
35c2c66affSColin Finck GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIME, szBuffer, ARRAYSIZE(szBuffer));
36c2c66affSColin Finck cTimeSeparator = szBuffer[0];
37c2c66affSColin Finck GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ITIME | LOCALE_RETURN_NUMBER, (LPTSTR)&nTimeFormat, sizeof(nTimeFormat) / sizeof(TCHAR));
38c2c66affSColin Finck
39c2c66affSColin Finck /* number settings */
40c2c66affSColin Finck GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, szBuffer, ARRAYSIZE(szBuffer));
41c2c66affSColin Finck cThousandSeparator = szBuffer[0];
42c2c66affSColin Finck GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szBuffer, ARRAYSIZE(szBuffer));
43c2c66affSColin Finck cDecimalSeparator = szBuffer[0];
44c2c66affSColin Finck GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, szBuffer, ARRAYSIZE(szBuffer));
45c2c66affSColin Finck nNumberGroups = _ttoi(szBuffer);
46c2c66affSColin Finck #if 0
47c2c66affSColin Finck /* days of week */
48c2c66affSColin Finck for (i = 0; i < 7; i++)
49c2c66affSColin Finck {
50c2c66affSColin Finck GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1 + i, szBuffer, ARRAYSIZE(szBuffer));
51c2c66affSColin Finck _tcscpy(aszDayNames[(i+1)%7], szBuffer); /* little hack */
52c2c66affSColin Finck }
53c2c66affSColin Finck #endif
54c2c66affSColin Finck }
55c2c66affSColin Finck
56*24a38b34SKatayama Hirofumi MZ /* Return date string without weekday. Used for $D in prompt and %DATE% */
57c2c66affSColin Finck LPTSTR
GetDateString(VOID)58c2c66affSColin Finck GetDateString(VOID)
59c2c66affSColin Finck {
60c2c66affSColin Finck static TCHAR szDate[32];
61c2c66affSColin Finck SYSTEMTIME t;
62c2c66affSColin Finck
63*24a38b34SKatayama Hirofumi MZ GetLocalTime(&t);
64*24a38b34SKatayama Hirofumi MZ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &t, NULL, szDate, ARRAYSIZE(szDate));
65c2c66affSColin Finck return szDate;
66c2c66affSColin Finck }
67c2c66affSColin Finck
68bea6d763SAndrew Dent /* Return time in H:mm:ss.SS format. Used for $T in prompt and %TIME% */
69c2c66affSColin Finck LPTSTR
GetTimeString(VOID)70c2c66affSColin Finck GetTimeString(VOID)
71c2c66affSColin Finck {
72c2c66affSColin Finck static TCHAR szTime[12];
73c2c66affSColin Finck SYSTEMTIME t;
74c2c66affSColin Finck GetLocalTime(&t);
75c2c66affSColin Finck _stprintf(szTime, _T("%2d%c%02d%c%02d%c%02d"),
76c2c66affSColin Finck t.wHour, cTimeSeparator, t.wMinute, cTimeSeparator,
77c2c66affSColin Finck t.wSecond, cDecimalSeparator, t.wMilliseconds / 10);
78c2c66affSColin Finck return szTime;
79c2c66affSColin Finck }
80