lemon/bits/windows.cc
changeset 558 f53d641aa967
parent 491 879c55700cd4
child 877 141f9c0db4a3
child 940 64260c0f58eb
equal deleted inserted replaced
0:50900dbcc37b 1:3bef95956be2
    26 #define WIN32_LEAN_AND_MEAN
    26 #define WIN32_LEAN_AND_MEAN
    27 #endif
    27 #endif
    28 #ifndef NOMINMAX
    28 #ifndef NOMINMAX
    29 #define NOMINMAX
    29 #define NOMINMAX
    30 #endif
    30 #endif
       
    31 #ifdef UNICODE
       
    32 #undef UNICODE
       
    33 #endif
    31 #include <windows.h>
    34 #include <windows.h>
       
    35 #ifdef LOCALE_INVARIANT
       
    36 #define MY_LOCALE LOCALE_INVARIANT
       
    37 #else
       
    38 #define MY_LOCALE LOCALE_NEUTRAL
       
    39 #endif
    32 #else
    40 #else
    33 #include <unistd.h>
    41 #include <unistd.h>
    34 #include <ctime>
    42 #include <ctime>
    35 #include <sys/times.h>
    43 #include <sys/times.h>
    36 #include <sys/time.h>
    44 #include <sys/time.h>
    85     {
    93     {
    86       std::ostringstream os;
    94       std::ostringstream os;
    87 #ifdef WIN32
    95 #ifdef WIN32
    88       SYSTEMTIME time;
    96       SYSTEMTIME time;
    89       GetSystemTime(&time);
    97       GetSystemTime(&time);
    90 #if defined(_MSC_VER) && (_MSC_VER < 1500)
    98       char buf1[11], buf2[9], buf3[5];
    91       LPWSTR buf1, buf2, buf3;
    99 	  if (GetDateFormat(MY_LOCALE, 0, &time,
    92       if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
   100                         ("ddd MMM dd"), buf1, 11) &&
    93                         L"ddd MMM dd", buf1, 11) &&
   101           GetTimeFormat(MY_LOCALE, 0, &time,
    94           GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
   102                         ("HH':'mm':'ss"), buf2, 9) &&
    95                         L"HH':'mm':'ss", buf2, 9) &&
   103           GetDateFormat(MY_LOCALE, 0, &time,
    96           GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
   104                         ("yyyy"), buf3, 5)) {
    97                         L"yyyy", buf3, 5)) {
       
    98         os << buf1 << ' ' << buf2 << ' ' << buf3;
   105         os << buf1 << ' ' << buf2 << ' ' << buf3;
    99       }
   106       }
   100 #else
       
   101       char buf1[11], buf2[9], buf3[5];
       
   102       if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
       
   103                         "ddd MMM dd", buf1, 11) &&
       
   104           GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
       
   105                         "HH':'mm':'ss", buf2, 9) &&
       
   106           GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
       
   107                         "yyyy", buf3, 5)) {
       
   108         os << buf1 << ' ' << buf2 << ' ' << buf3;
       
   109       }
       
   110 #endif
       
   111       else os << "unknown";
   107       else os << "unknown";
   112 #else
   108 #else
   113       timeval tv;
   109       timeval tv;
   114       gettimeofday(&tv, 0);
   110       gettimeofday(&tv, 0);
   115 
   111