Further fixes to windows.cc (#215)
authorJanos Tapolcai <tapolcai@tmit.bme.hu>
Tue, 17 Feb 2009 18:10:07 +0100
changeset 3703f0ddf255524
parent 368 879c55700cd4
child 371 14a7e712e80f
Further fixes to windows.cc (#215)
lemon/bits/windows.cc
     1.1 --- a/lemon/bits/windows.cc	Mon Feb 16 15:03:32 2009 +0000
     1.2 +++ b/lemon/bits/windows.cc	Tue Feb 17 18:10:07 2009 +0100
     1.3 @@ -28,7 +28,15 @@
     1.4  #ifndef NOMINMAX
     1.5  #define NOMINMAX
     1.6  #endif
     1.7 +#ifdef UNICODE
     1.8 +#undef UNICODE
     1.9 +#endif
    1.10  #include <windows.h>
    1.11 +#ifdef LOCALE_INVARIANT
    1.12 +#define MY_LOCALE LOCALE_INVARIANT
    1.13 +#else
    1.14 +#define MY_LOCALE LOCALE_NEUTRAL
    1.15 +#endif
    1.16  #else
    1.17  #include <unistd.h>
    1.18  #include <ctime>
    1.19 @@ -87,27 +95,15 @@
    1.20  #ifdef WIN32
    1.21        SYSTEMTIME time;
    1.22        GetSystemTime(&time);
    1.23 -#if defined(_MSC_VER) && (_MSC_VER < 1500)
    1.24 -      LPWSTR buf1, buf2, buf3;
    1.25 -      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
    1.26 -                        L"ddd MMM dd", buf1, 11) &&
    1.27 -          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
    1.28 -                        L"HH':'mm':'ss", buf2, 9) &&
    1.29 -          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
    1.30 -                        L"yyyy", buf3, 5)) {
    1.31 +      char buf1[11], buf2[9], buf3[5];
    1.32 +	  if (GetDateFormat(MY_LOCALE, 0, &time,
    1.33 +                        ("ddd MMM dd"), buf1, 11) &&
    1.34 +          GetTimeFormat(MY_LOCALE, 0, &time,
    1.35 +                        ("HH':'mm':'ss"), buf2, 9) &&
    1.36 +          GetDateFormat(MY_LOCALE, 0, &time,
    1.37 +                        ("yyyy"), buf3, 5)) {
    1.38          os << buf1 << ' ' << buf2 << ' ' << buf3;
    1.39        }
    1.40 -#else
    1.41 -      char buf1[11], buf2[9], buf3[5];
    1.42 -      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
    1.43 -                        "ddd MMM dd", buf1, 11) &&
    1.44 -          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
    1.45 -                        "HH':'mm':'ss", buf2, 9) &&
    1.46 -          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
    1.47 -                        "yyyy", buf3, 5)) {
    1.48 -        os << buf1 << ' ' << buf2 << ' ' << buf3;
    1.49 -      }
    1.50 -#endif
    1.51        else os << "unknown";
    1.52  #else
    1.53        timeval tv;