ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

locale.c
Go to the documentation of this file.
00001 /*
00002  *  LOCALE.C - locale handling.
00003  *
00004  *
00005  *  History:
00006  *
00007  *    09-Jan-1999 (Eric Kohl)
00008  *        Started.
00009  *
00010  *    20-Jan-1999 (Eric Kohl)
00011  *        Unicode safe!
00012  */
00013 
00014 #include <precomp.h>
00015 
00016 
00017 TCHAR cDateSeparator;
00018 TCHAR cTimeSeparator;
00019 TCHAR cThousandSeparator;
00020 TCHAR cDecimalSeparator;
00021 INT   nDateFormat;
00022 INT   nTimeFormat;
00023 INT   nNumberGroups;
00024 
00025 
00026 VOID InitLocale (VOID)
00027 {
00028     TCHAR szBuffer[256];
00029 
00030     /* date settings */
00031     GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SDATE, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
00032     cDateSeparator = szBuffer[0];
00033     GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IDATE | LOCALE_RETURN_NUMBER, (LPTSTR)&nDateFormat, sizeof(nDateFormat) / sizeof(TCHAR));
00034 
00035     /* time settings */
00036     GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STIME, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
00037     cTimeSeparator = szBuffer[0];
00038     GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ITIME | LOCALE_RETURN_NUMBER, (LPTSTR)&nTimeFormat, sizeof(nTimeFormat) / sizeof(TCHAR));
00039 
00040     /* number settings */
00041     GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
00042     cThousandSeparator = szBuffer[0];
00043     GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
00044     cDecimalSeparator  = szBuffer[0];
00045         GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SGROUPING, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
00046         nNumberGroups = _ttoi(szBuffer);
00047 #if 0
00048     /* days of week */
00049     for (i = 0; i < 7; i++)
00050     {
00051         GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1 + i, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
00052         _tcscpy (aszDayNames[(i+1)%7], szBuffer); /* little hack */
00053     }
00054 #endif
00055 }
00056 
00057 /* Return date string including weekday. Used for $D in prompt and %DATE% */
00058 LPTSTR
00059 GetDateString(VOID)
00060 {
00061     static TCHAR szDate[32];
00062     SYSTEMTIME t;
00063     INT len;
00064     GetLocalTime(&t);
00065 
00066     len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &t, _T("ddd"), szDate, sizeof szDate);
00067     szDate[len - 1] = _T(' ');
00068     FormatDate(&szDate[len], &t, TRUE);
00069     return szDate;
00070 }
00071 
00072 /* Return time in hh:mm:ss.xx format. Used for $T in prompt and %TIME% */
00073 LPTSTR
00074 GetTimeString(VOID)
00075 {
00076     static TCHAR szTime[12];
00077     SYSTEMTIME t;
00078     GetLocalTime(&t);
00079     _stprintf(szTime, _T("%2d%c%02d%c%02d%c%02d"),
00080         t.wHour, cTimeSeparator, t.wMinute, cTimeSeparator,
00081         t.wSecond, cDecimalSeparator, t.wMilliseconds / 10);
00082     return szTime;
00083 }

Generated on Sat May 26 2012 04:17:03 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.