Ignore:
Timestamp:
Sep 3, 2000, 8:05:40 PM (25 years ago)
Author:
phaller
Message:

WINE NLS sync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/time.cpp

    r3588 r4174  
    1 /* $Id: time.cpp,v 1.8 2000-05-22 19:07:59 sandervl Exp $ */
     1/* $Id: time.cpp,v 1.9 2000-09-03 18:04:56 phaller Exp $ */
    22
    33/*
     
    568568}
    569569
    570 /******************************************************************************
    571  *              OLE2NLS_CheckLocale     [intern]
    572  */
    573 static LCID OLE2NLS_CheckLocale (LCID locale)
    574 {
    575         if (!locale)
    576         { locale = LOCALE_SYSTEM_DEFAULT;
    577         }
    578 
    579         if (locale == LOCALE_SYSTEM_DEFAULT)
    580         { return GetSystemDefaultLCID();
    581         }
    582         else if (locale == LOCALE_USER_DEFAULT)
    583         { return GetUserDefaultLCID();
    584         }
    585         else
    586         { return locale;
    587         }
    588 }
    589 
    590 /******************************************************************************
    591  *              OLE_GetFormatA  [Internal]
    592  *
    593  * FIXME
    594  *    If datelen == 0, it should return the reguired string length.
    595  *
    596  This function implements stuff for GetDateFormat() and
    597  GetTimeFormat().
    598   d    single-digit (no leading zero) day (of month)
    599   dd   two-digit day (of month)
    600   ddd  short day-of-week name
    601   dddd long day-of-week name
    602   M    single-digit month
    603   MM   two-digit month
    604   MMM  short month name
    605   MMMM full month name
    606   y    two-digit year, no leading 0
    607   yy   two-digit year
    608   yyyy four-digit year
    609   gg   era string
    610   h    hours with no leading zero (12-hour)
    611   hh   hours with full two digits
    612   H    hours with no leading zero (24-hour)
    613   HH   hours with full two digits
    614   m    minutes with no leading zero
    615   mm   minutes with full two digits
    616   s    seconds with no leading zero
    617   ss   seconds with full two digits
    618   t    time marker (A or P)
    619   tt   time marker (AM, PM)
    620   ''   used to quote literal characters
    621   ''   (within a quoted string) indicates a literal '
    622  These functions REQUIRE valid locale, date,  and format.
    623  */
    624 static INT OLE_GetFormatA(LCID locale,
    625                             DWORD flags,
    626                             DWORD tflags,
    627                             LPSYSTEMTIME xtime,
    628                             LPCSTR _format,     /*in*/
    629                             LPSTR date,         /*out*/
    630                             INT datelen)
    631 {
    632    INT inpos, outpos;
    633    int count, type, inquote, Overflow;
    634    char buf[40];
    635    char format[40];
    636    char * pos;
    637    int buflen;
    638    const char * _dgfmt[] = { "%d", "%02d" };
    639    const char ** dgfmt = _dgfmt - 1;
    640    dprintf(("KERNEL32: OLE_GetFormatA"));
    641 
    642    if(datelen == 0) {
    643      //FIXME_(ole)("datelen = 0, returning 255\n");
    644      return 255;
    645    }
    646    /* initalize state variables and output buffer */
    647    inpos = outpos = 0;
    648    count = 0; inquote = 0; Overflow = 0;
    649    type = '\0';
    650    date[0] = buf[0] = '\0';
    651 
    652    strcpy(format,_format);
    653    /* alter the formatstring, while it works for all languages now in wine
    654    its possible that it fails when the time looks like ss:mm:hh as example*/
    655    if (tflags & (TIME_NOMINUTESORSECONDS))
    656    { if ((pos = strstr ( format, ":mm")) != 0)
    657      { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
    658      }
    659    }
    660    if (tflags & (TIME_NOSECONDS))
    661    { if ((pos = strstr ( format, ":ss")) != 0)
    662      { memcpy ( pos, pos+3, strlen(format)-(pos-format)-2 );
    663      }
    664    }
    665 
    666    for (inpos = 0;; inpos++) {
    667       /* TRACE(ole, "STATE inpos=%2d outpos=%2d count=%d inquote=%d type=%c buf,date = %c,%c\n", inpos, outpos, count, inquote, type, buf[inpos], date[outpos]); */
    668       if (inquote) {
    669          if (format[inpos] == '\'') {
    670             if (format[inpos+1] == '\'') {
    671                inpos += 1;
    672                date[outpos++] = '\'';
    673             } else {
    674                inquote = 0;
    675                continue; /* we did nothing to the output */
    676             }
    677          } else if (format[inpos] == '\0') {
    678             date[outpos++] = '\0';
    679             if (outpos > datelen) Overflow = 1;
    680             break;
    681          } else {
    682             date[outpos++] = format[inpos];
    683             if (outpos > datelen) {
    684                Overflow = 1;
    685                date[outpos-1] = '\0'; /* this is the last place where
    686                                          it's safe to write */
    687                break;
    688             }
    689          }
    690       } else if (  (count && (format[inpos] != type))
    691                    || count == 4
    692                    || (count == 2 && strchr("ghHmst", type)) )
    693        {
    694             if         (type == 'd') {
    695                if        (count == 4) {
    696                   GetLocaleInfoA(locale,
    697                                    LOCALE_SDAYNAME1
    698                                    + xtime->wDayOfWeek - 1,
    699                                    buf, sizeof(buf));
    700                } else if (count == 3) {
    701                            GetLocaleInfoA(locale,
    702                                             LOCALE_SABBREVDAYNAME1
    703                                             + xtime->wDayOfWeek - 1,
    704                                             buf, sizeof(buf));
    705                       } else {
    706                   sprintf(buf, dgfmt[count], xtime->wDay);
    707                }
    708             } else if (type == 'M') {
    709                if (count == 3) {
    710                   GetLocaleInfoA(locale,
    711                                    LOCALE_SABBREVMONTHNAME1
    712                                    + xtime->wMonth - 1,
    713                                    buf, sizeof(buf));
    714                } else if (count == 4) {
    715                   GetLocaleInfoA(locale,
    716                                    LOCALE_SMONTHNAME1
    717                                    + xtime->wMonth - 1,
    718                                    buf, sizeof(buf));
    719                  } else {
    720                   sprintf(buf, dgfmt[count], xtime->wMonth);
    721                }
    722             } else if (type == 'y') {
    723                if (count == 4) {
    724                       sprintf(buf, "%d", xtime->wYear);
    725                } else if (count == 3) {
    726                   strcpy(buf, "yyy");
    727                   //WARN_(ole)("unknown format, c=%c, n=%d\n",  type, count);
    728                  } else {
    729                   sprintf(buf, dgfmt[count], xtime->wYear % 100);
    730                }
    731             } else if (type == 'g') {
    732                if        (count == 2) {
    733                   //FIXME_(ole)("LOCALE_ICALENDARTYPE unimp.\n");
    734                   strcpy(buf, "AD");
    735             } else {
    736                   strcpy(buf, "g");
    737                   //WARN_(ole)("unknown format, c=%c, n=%d\n", type, count);
    738                }
    739             } else if (type == 'h') {
    740                /* gives us hours 1:00 -- 12:00 */
    741                sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1);
    742             } else if (type == 'H') {
    743                /* 24-hour time */
    744                sprintf(buf, dgfmt[count], xtime->wHour);
    745             } else if ( type == 'm') {
    746                sprintf(buf, dgfmt[count], xtime->wMinute);
    747             } else if ( type == 's') {
    748                sprintf(buf, dgfmt[count], xtime->wSecond);
    749             } else if (type == 't') {
    750                if        (count == 1) {
    751                   sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
    752                } else if (count == 2) {
    753                   /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
    754                   GetLocaleInfoA(locale,
    755                                    (xtime->wHour<12)
    756                                    ? LOCALE_S1159 : LOCALE_S2359,
    757                                    buf, sizeof(buf));
    758                }
    759             };
    760             /* we need to check the next char in the format string
    761                again, no matter what happened */
    762             inpos--;
    763        
    764             /* add the contents of buf to the output */
    765             buflen = strlen(buf);
    766             if (outpos + buflen < datelen) {
    767                date[outpos] = '\0'; /* for strcat to hook onto */
    768                  strcat(date, buf);
    769                outpos += buflen;
    770             } else {
    771                date[outpos] = '\0';
    772                strncat(date, buf, datelen - outpos);
    773                  date[datelen - 1] = '\0';
    774                  SetLastError(ERROR_INSUFFICIENT_BUFFER);
    775                //WARN_(ole)("insufficient buffer\n");
    776                  return 0;
    777             }
    778             /* reset the variables we used to keep track of this item */
    779             count = 0;
    780             type = '\0';
    781          } else if (format[inpos] == '\0') {
    782             /* we can't check for this at the loop-head, because
    783                that breaks the printing of the last format-item */
    784             date[outpos] = '\0';
    785             break;
    786          } else if (count) {
    787             /* continuing a code for an item */
    788             count +=1;
    789             continue;
    790          } else if (strchr("hHmstyMdg", format[inpos])) {
    791             type = format[inpos];
    792             count = 1;
    793             continue;
    794          } else if (format[inpos] == '\'') {
    795             inquote = 1;
    796             continue;
    797        } else {
    798             date[outpos++] = format[inpos];
    799          }
    800       /* now deal with a possible buffer overflow */
    801       if (outpos >= datelen) {
    802        date[datelen - 1] = '\0';
    803        SetLastError(ERROR_INSUFFICIENT_BUFFER);
    804        return 0;
    805       }
    806    }
    807 
    808    if (Overflow) {
    809       SetLastError(ERROR_INSUFFICIENT_BUFFER);
    810    };
    811    /* finish it off with a string terminator */
    812    outpos++;
    813    /* sanity check */
    814    if (outpos > datelen-1) outpos = datelen-1;
    815    date[outpos] = '\0';
    816 
    817    //TRACE_(ole)("OLE_GetFormatA returns string '%s', len %d\n",
    818    //          date, outpos);
    819    return outpos;
    820 }
    821 
    822 /******************************************************************************
    823  * OLE_GetFormatW [INTERNAL]
    824  */
    825 static INT OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags,
    826                             LPSYSTEMTIME xtime,
    827                             LPCWSTR format,
    828                             LPWSTR output, INT outlen)
    829 {
    830    INT   inpos, outpos;
    831    int     count, type=0, inquote;
    832    int     Overflow; /* loop check */
    833    WCHAR   buf[40];
    834    int     buflen=0;
    835    WCHAR   arg0[] = {0}, arg1[] = {'%','d',0};
    836    WCHAR   arg2[] = {'%','0','2','d',0};
    837    WCHAR  *argarr[3];
    838    int     datevars=0, timevars=0;
    839    argarr[0] = arg0;
    840    argarr[1] = arg1;
    841    argarr[2] = arg2;
    842 
    843    dprintf(("KERNEL32: OLE_GetFormatW"));
    844 
    845    if(outlen == 0) {
    846      //FIXME_(ole)("outlen = 0, returning 255\n");
    847      return 255;
    848    }
    849    /* initialize state variables */
    850    inpos = outpos = 0;
    851    count = 0;
    852    inquote = Overflow = 0;
    853    /* this is really just a sanity check */
    854    output[0] = buf[0] = 0;
    855 
    856    /* this loop is the core of the function */
    857    for (inpos = 0; /* we have several break points */ ; inpos++) {
    858       if (inquote) {
    859          if (format[inpos] == (WCHAR) '\'') {
    860             if (format[inpos+1] == '\'') {
    861                inpos++;
    862                output[outpos++] = '\'';
    863             } else {
    864                inquote = 0;
    865                continue;
    866             }
    867          } else if (format[inpos] == 0) {
    868             output[outpos++] = 0;
    869             if (outpos > outlen) Overflow = 1;
    870             break;  /*  normal exit (within a quote) */
    871          } else {
    872             output[outpos++] = format[inpos]; /* copy input */
    873             if (outpos > outlen) {
    874                Overflow = 1;
    875                output[outpos-1] = 0;
    876                break;
    877             }
    878          }
    879       } else if (  (count && (format[inpos] != type))
    880                    || ( (count==4 && type =='y') ||
    881                         (count==4 && type =='M') ||
    882                         (count==4 && type =='d') ||
    883                         (count==2 && type =='g') ||
    884                         (count==2 && type =='h') ||
    885                         (count==2 && type =='H') ||
    886                         (count==2 && type =='m') ||
    887                         (count==2 && type =='s') ||
    888                         (count==2 && type =='t') )  ) {
    889          if        (type == 'd') {
    890             if        (count == 3) {
    891                GetLocaleInfoW(locale,
    892                              LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,
    893                              buf, sizeof(buf)/sizeof(WCHAR) );
    894             } else if (count == 3) {
    895                GetLocaleInfoW(locale,
    896                                 LOCALE_SABBREVDAYNAME1 +
    897                                 xtime->wDayOfWeek -1,
    898                                 buf, sizeof(buf)/sizeof(WCHAR) );
    899             } else {
    900                wsnprintfW(buf, 5, argarr[count], xtime->wDay );
    901             };
    902          } else if (type == 'M') {
    903             if        (count == 4) {
    904                GetLocaleInfoW(locale,  LOCALE_SMONTHNAME1 +
    905                                 xtime->wMonth -1, buf,
    906                                 sizeof(buf)/sizeof(WCHAR) );
    907             } else if (count == 3) {
    908                GetLocaleInfoW(locale,  LOCALE_SABBREVMONTHNAME1 +
    909                                 xtime->wMonth -1, buf,
    910                                 sizeof(buf)/sizeof(WCHAR) );
    911             } else {
    912                wsnprintfW(buf, 5, argarr[count], xtime->wMonth);
    913             }
    914          } else if (type == 'y') {
    915             if        (count == 4) {
    916                wsnprintfW(buf, 6, argarr[1] /* "%d" */,
    917                          xtime->wYear);
    918             } else if (count == 3) {
    919                lstrcpynAtoW(buf, "yyy", 5);
    920             } else {
    921                wsnprintfW(buf, 6, argarr[count],
    922                             xtime->wYear % 100);
    923             }
    924          } else if (type == 'g') {
    925             if        (count == 2) {
    926                //FIXME_(ole)("LOCALE_ICALENDARTYPE unimplemented\n");
    927                lstrcpynAtoW(buf, "AD", 5);
    928             } else {
    929                /* Win API sez we copy it verbatim */
    930                lstrcpynAtoW(buf, "g", 5);
    931             }
    932          } else if (type == 'h') {
    933             /* hours 1:00-12:00 --- is this right? */
    934             wsnprintfW(buf, 5, argarr[count],
    935                          (xtime->wHour-1)%12 +1);
    936          } else if (type == 'H') {
    937             wsnprintfW(buf, 5, argarr[count],
    938                          xtime->wHour);
    939          } else if (type == 'm' ) {
    940             wsnprintfW(buf, 5, argarr[count],
    941                          xtime->wMinute);
    942          } else if (type == 's' ) {
    943             wsnprintfW(buf, 5, argarr[count],
    944                          xtime->wSecond);
    945          } else if (type == 't') {
    946             GetLocaleInfoW(locale, (xtime->wHour < 12) ?
    947                              LOCALE_S1159 : LOCALE_S2359,
    948                              buf, sizeof(buf) );
    949             if        (count == 1) {
    950                buf[1] = 0;
    951             }
    952 }
    953          /* no matter what happened,  we need to check this next
    954             character the next time we loop through */
    955          inpos--;
    956          /* cat buf onto the output */
    957          outlen = lstrlenW(buf);
    958          if (outpos + buflen < outlen) {
    959             lstrcpyW( output + outpos, buf );
    960             outpos += buflen;
    961          } else {
    962             lstrcpynW( output + outpos, buf, outlen - outpos );
    963             Overflow = 1;
    964             break; /* Abnormal exit */
    965          }
    966          /* reset the variables we used this time */
    967          count = 0;
    968          type = '\0';
    969       } else if (format[inpos] == 0) {
    970          /* we can't check for this at the beginning,  because that
    971          would keep us from printing a format spec that ended the
    972          string */
    973          output[outpos] = 0;
    974          break;  /*  NORMAL EXIT  */
    975       } else if (count) {
    976          /* how we keep track of the middle of a format spec */
    977          count++;
    978          continue;
    979       } else if ( (datevars && (format[inpos]=='d' ||
    980                                 format[inpos]=='M' ||
    981                                 format[inpos]=='y' ||
    982                                 format[inpos]=='g')  ) ||
    983                   (timevars && (format[inpos]=='H' ||
    984                                 format[inpos]=='h' ||
    985                                 format[inpos]=='m' ||
    986                                 format[inpos]=='s' ||
    987                                 format[inpos]=='t') )    ) {
    988          type = format[inpos];
    989          count = 1;
    990          continue;
    991       } else if (format[inpos] == '\'') {
    992          inquote = 1;
    993          continue;
    994       } else {
    995          /* unquoted literals */
    996          output[outpos++] = format[inpos];
    997       }
    998    }
    999    if (Overflow) {
    1000       SetLastError(ERROR_INSUFFICIENT_BUFFER);
    1001       //WARN_(ole)(" buffer overflow\n");
    1002    };
    1003    /* final string terminator and sanity check */
    1004    outpos++;
    1005    if (outpos > outlen-1) outpos = outlen-1;
    1006    output[outpos] = '0';
    1007    //TRACE_(ole)(" returning %s\n", debugstr_w(output));
    1008        
    1009    return (!Overflow) ? outlen : 0;
    1010 
    1011 }
    1012 
    1013 /******************************************************************************
    1014  *              GetTimeFormat32A        [KERNEL32.422]
    1015  * Makes an ASCII string of the time
    1016  *
    1017  * Formats date according to format,  or locale default if format is
    1018  * NULL. The format consists of literal characters and fields as follows:
    1019  *
    1020  * h  hours with no leading zero (12-hour)
    1021  * hh hours with full two digits
    1022  * H  hours with no leading zero (24-hour)
    1023  * HH hours with full two digits
    1024  * m  minutes with no leading zero
    1025  * mm minutes with full two digits
    1026  * s  seconds with no leading zero
    1027  * ss seconds with full two digits
    1028  * t  time marker (A or P)
    1029  * tt time marker (AM, PM)
    1030  *
    1031  */
    1032 INT WINAPI
    1033 GetTimeFormatA(LCID locale,        /* in  */
    1034                  DWORD flags,        /* in  */
    1035                  LPSYSTEMTIME xtime, /* in  */
    1036                  LPCSTR format,      /* in  */
    1037                  LPSTR timestr,      /* out */
    1038                  INT timelen       /* in  */)
    1039 { char format_buf[40];
    1040   LPCSTR thisformat;
    1041   SYSTEMTIME t;
    1042   LPSYSTEMTIME thistime;
    1043   LCID thislocale=0;
    1044   DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
    1045   INT ret;
    1046 
    1047   dprintf(("KERNEL32: GetTimeFormatA"));
    1048   //TRACE_(ole)("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen);
    1049   thislocale = OLE2NLS_CheckLocale ( locale );
    1050   if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
    1051   { //FIXME_(ole)("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
    1052   }
    1053 
    1054   flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
    1055   if (format == NULL)
    1056   { if (flags & LOCALE_NOUSEROVERRIDE)  /*use system default*/
    1057     { thislocale = GetSystemDefaultLCID();
    1058     }
    1059     GetLocaleInfoA(thislocale, thisflags, format_buf, sizeof(format_buf));
    1060     thisformat = format_buf;
    1061   }
    1062   else
    1063   { thisformat = format;
    1064   }
    1065 
    1066   if (xtime == NULL) /* NULL means use the current local time*/
    1067   { GetLocalTime(&t);
    1068     thistime = &t;
    1069   }
    1070   else
    1071   { thistime = xtime;
    1072   }
    1073   ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat,
    1074                          timestr, timelen);
    1075   return ret;
    1076 }
    1077 
    1078 /******************************************************************************
    1079  *              GetTimeFormat32W        [KERNEL32.423]
    1080  * Makes a Unicode string of the time
    1081  */
    1082 INT WINAPI
    1083 GetTimeFormatW(LCID locale,        /* in  */
    1084                  DWORD flags,        /* in  */
    1085                  LPSYSTEMTIME xtime, /* in  */
    1086                  LPCWSTR format,     /* in  */
    1087                  LPWSTR timestr,     /* out */
    1088                  INT timelen       /* in  */)
    1089 {       WCHAR format_buf[40];
    1090         LPCWSTR thisformat;
    1091         SYSTEMTIME t;
    1092         LPSYSTEMTIME thistime;
    1093         LCID thislocale=0;
    1094         DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
    1095         INT ret;
    1096        
    1097         dprintf(("KERNEL32: GetTimeFormatW"));
    1098         //TRACE_(ole)("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,
    1099         //xtime,debugstr_w(format),timestr,timelen);
    1100         thislocale = OLE2NLS_CheckLocale ( locale );
    1101         if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
    1102         { //FIXME_(ole)("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
    1103         }
    1104 
    1105         flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
    1106         if (format == NULL)
    1107         { if (flags & LOCALE_NOUSEROVERRIDE)  /*use system default*/
    1108           { thislocale = GetSystemDefaultLCID();
    1109           }
    1110           GetLocaleInfoW(thislocale, thisflags, format_buf, 40);
    1111           thisformat = format_buf;
    1112         }       
    1113         else
    1114         { thisformat = format;
    1115         }
    1116 
    1117         if (xtime == NULL) /* NULL means use the current local time*/
    1118         { GetSystemTime(&t);
    1119           thistime = &t;
    1120         }
    1121         else
    1122         { thistime = xtime;
    1123         }
    1124         ret = OLE_GetFormatW(thislocale, thisflags, flags, thistime, thisformat,
    1125                          timestr, timelen);
    1126         return ret;
    1127 }
    1128 
    1129 /******************************************************************************
    1130  *              GetDateFormat32A        [KERNEL32.310]
    1131  * Makes an ASCII string of the date
    1132  *
    1133  * This function uses format to format the date,  or,  if format
    1134  * is NULL, uses the default for the locale.  format is a string
    1135  * of literal fields and characters as follows:
    1136  *
    1137  * - d    single-digit (no leading zero) day (of month)
    1138  * - dd   two-digit day (of month)
    1139  * - ddd  short day-of-week name
    1140  * - dddd long day-of-week name
    1141  * - M    single-digit month
    1142  * - MM   two-digit month
    1143  * - MMM  short month name
    1144  * - MMMM full month name
    1145  * - y    two-digit year, no leading 0
    1146  * - yy   two-digit year
    1147  * - yyyy four-digit year
    1148  * - gg   era string
    1149  *
    1150  */
    1151 INT WINAPI GetDateFormatA(LCID locale,DWORD flags,
    1152                               LPSYSTEMTIME xtime,
    1153                               LPCSTR format, LPSTR date,INT datelen)
    1154 {
    1155   char format_buf[40];
    1156   LPCSTR thisformat;
    1157   SYSTEMTIME t;
    1158   LPSYSTEMTIME thistime;
    1159   LCID thislocale;
    1160   INT ret;
    1161 
    1162   dprintf(("KERNEL32: GetDateFormatA\n"));
    1163 
    1164   if (!locale) {
    1165      locale = LOCALE_SYSTEM_DEFAULT;
    1166      };
    1167 
    1168   if (locale == LOCALE_SYSTEM_DEFAULT) {
    1169      thislocale = GetSystemDefaultLCID();
    1170   } else if (locale == LOCALE_USER_DEFAULT) {
    1171      thislocale = GetUserDefaultLCID();
    1172   } else {
    1173      thislocale = locale;
    1174    };
    1175   if (xtime == NULL) {
    1176      GetSystemTime(&t);
    1177      thistime = &t;
    1178   } else {
    1179      thistime = xtime;
    1180   };
    1181   if (format == NULL) {
    1182      GetLocaleInfoA(thislocale, ((flags&DATE_LONGDATE)
    1183                                    ? LOCALE_SLONGDATE
    1184                                    : LOCALE_SSHORTDATE),
    1185                       format_buf, sizeof(format_buf));
    1186      thisformat = format_buf;
    1187   } else {
    1188      thisformat = format;
    1189   };
    1190 
    1191   ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat,
    1192                        date, datelen);
    1193 
    1194   return ret;
    1195 }
    1196 /******************************************************************************
    1197  *              GetDateFormat32W        [KERNEL32.311]
    1198  * Makes a Unicode string of the date
    1199  *
    1200  * Acts the same as GetDateFormat32A(),  except that it's Unicode.
    1201  * Accepts & returns sizes as counts of Unicode characters.
    1202  *
    1203  */
    1204 INT WINAPI GetDateFormatW(LCID locale,DWORD flags,
    1205                               LPSYSTEMTIME xtime,
    1206                               LPCWSTR format,
    1207                               LPWSTR date, INT datelen)
    1208 {
    1209   WCHAR format_buf[40];
    1210   LPWSTR thisformat;
    1211   SYSTEMTIME t;
    1212   LPSYSTEMTIME thistime;
    1213   LCID thislocale;
    1214   INT ret;
    1215 
    1216   dprintf(("KERNEL32: GetDateFormatW\n"));
    1217 
    1218   if (!locale) {
    1219      locale = LOCALE_SYSTEM_DEFAULT;
    1220      };
    1221 
    1222   if (locale == LOCALE_SYSTEM_DEFAULT) {
    1223      thislocale = GetSystemDefaultLCID();
    1224   } else if (locale == LOCALE_USER_DEFAULT) {
    1225      thislocale = GetUserDefaultLCID();
    1226   } else {
    1227      thislocale = locale;
    1228    };
    1229   if (xtime == NULL) {
    1230      GetSystemTime(&t);
    1231      thistime = &t;
    1232   } else {
    1233      thistime = xtime;
    1234   };
    1235   if (format == NULL) {
    1236      GetLocaleInfoW(thislocale, ((flags&DATE_LONGDATE)
    1237                                    ? LOCALE_SLONGDATE
    1238                                    : LOCALE_SSHORTDATE),
    1239                       format_buf, sizeof(format_buf));
    1240      thisformat = format_buf;
    1241   } else {
    1242      thisformat = (WCHAR*)format;
    1243   };
    1244 
    1245   ret = OLE_GetFormatW(thislocale, flags, 0, thistime, thisformat,
    1246                        date, datelen);
    1247 
    1248   return ret;
    1249 }
    1250 /**************************************************************************
    1251  *              EnumTimeFormats32A      (KERNEL32.210)
    1252  */
    1253 BOOL WINAPI EnumTimeFormatsA(
    1254   TIMEFMT_ENUMPROCA lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
    1255 {
    1256   dprintf(("KERNEL32: EnumTimeFormatsA: only US English supported\n"));
    1257 
    1258   if(!lpTimeFmtEnumProc)
    1259     {
    1260       SetLastError(ERROR_INVALID_PARAMETER);
    1261       return FALSE;
    1262     }
    1263   if(dwFlags)
    1264     {
    1265       //FIXME_(ole)("Unknown time format (%ld)\n", dwFlags);
    1266     }
    1267 
    1268   if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE;
    1269   if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE;
    1270   if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE;
    1271   if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE;
    1272 
    1273   return TRUE;
    1274 }
    1275 /**************************************************************************
    1276  *              EnumTimeFormats32W      (KERNEL32.211)
    1277  */
    1278 BOOL WINAPI EnumTimeFormatsW(
    1279   TIMEFMT_ENUMPROCW lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags)
    1280 {
    1281   WCHAR buf[20];
    1282 
    1283   dprintf(("KERNEL32: EnumTimeFormatsW: only US English supported\n"));
    1284 
    1285   if(!lpTimeFmtEnumProc)
    1286     {
    1287       SetLastError(ERROR_INVALID_PARAMETER);
    1288       return FALSE;
    1289     }
    1290   if(dwFlags)
    1291     {
    1292       //FIXME_(ole)("Unknown time format (%ld)\n", dwFlags);
    1293     }
    1294 
    1295   AsciiToUnicode("h:mm:ss tt",buf);
    1296   if(!(*lpTimeFmtEnumProc)(buf)) return TRUE;
    1297   AsciiToUnicode("hh:mm:ss tt",buf);
    1298   if(!(*lpTimeFmtEnumProc)(buf)) return TRUE;
    1299   AsciiToUnicode("H:mm:ss",buf);
    1300   if(!(*lpTimeFmtEnumProc)(buf)) return TRUE;
    1301   AsciiToUnicode("HH:mm:ss",buf);
    1302   if(!(*lpTimeFmtEnumProc)(buf)) return TRUE;
    1303 
    1304   return TRUE;
    1305 }
     570
    1306571/*****************************************************************************
    1307572 * Name      : DWORD GetSystemTimeAsFileTime
     
    1327592  SystemTimeToFileTime(&st, &ft);
    1328593}
    1329 /**************************************************************************
    1330  *              EnumDateFormats32A      (KERNEL32.198)
    1331  */
    1332 BOOL WINAPI EnumDateFormatsA(
    1333   DATEFMT_ENUMPROCA lpDateFmtEnumProc, LCID Locale,  DWORD dwFlags)
    1334 {
    1335   dprintf(("KERNEL32: EnumDateFormatsA: only US English supported\n"));
    1336 
    1337   if(!lpDateFmtEnumProc)
    1338     {
    1339       SetLastError(ERROR_INVALID_PARAMETER);
    1340       return FALSE;
    1341     }
    1342   switch(dwFlags)
    1343     {
    1344       case DATE_SHORTDATE:
    1345         if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
    1346         if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
    1347         if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
    1348         if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
    1349         if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
    1350         if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
    1351         return TRUE;
    1352       case DATE_LONGDATE:
    1353         if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
    1354         if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
    1355         if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
    1356         if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
    1357         return TRUE;
    1358       default:
    1359         //FIXME_(ole)("Unknown date format (%ld)\n", dwFlags);
    1360         SetLastError(ERROR_INVALID_PARAMETER);
    1361         return FALSE;
    1362     }
    1363 }
    1364 /**************************************************************************
    1365  *              EnumDateFormats32W      (KERNEL32.199)
    1366  */
    1367 BOOL WINAPI EnumDateFormatsW(
    1368   DATEFMT_ENUMPROCW lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
    1369 {
    1370   WCHAR buf[50];
    1371 
    1372   dprintf(("KERNEL32: EnumDateFormatsW: only US English supported\n"));
    1373 
    1374   if(!lpDateFmtEnumProc)
    1375     {
    1376       SetLastError(ERROR_INVALID_PARAMETER);
    1377       return FALSE;
    1378     }
    1379   switch(dwFlags)
    1380     {
    1381       case DATE_SHORTDATE:
    1382         AsciiToUnicode("M/d/yy",buf);
    1383         if(!(*lpDateFmtEnumProc)(buf)) return TRUE;
    1384         AsciiToUnicode("M/d/yyyy",buf);
    1385         if(!(*lpDateFmtEnumProc)(buf)) return TRUE;
    1386         AsciiToUnicode("MM/dd/yy",buf);
    1387         if(!(*lpDateFmtEnumProc)(buf)) return TRUE;
    1388         AsciiToUnicode("MM/dd/yyyy",buf);
    1389         if(!(*lpDateFmtEnumProc)(buf)) return TRUE;
    1390         AsciiToUnicode("yy/MM/dd",buf);
    1391         if(!(*lpDateFmtEnumProc)(buf)) return TRUE;
    1392         AsciiToUnicode("dd-MMM-yy",buf);
    1393         if(!(*lpDateFmtEnumProc)(buf)) return TRUE;
    1394         return TRUE;
    1395       case DATE_LONGDATE:
    1396         AsciiToUnicode("dddd, MMMM dd, yyyy",buf);
    1397         if(!(*lpDateFmtEnumProc)(buf)) return TRUE;
    1398         AsciiToUnicode("MMMM dd, yyyy",buf);
    1399         if(!(*lpDateFmtEnumProc)(buf)) return TRUE;
    1400         AsciiToUnicode("dddd, dd MMMM, yyyy",buf);
    1401         if(!(*lpDateFmtEnumProc)(buf)) return TRUE;
    1402         AsciiToUnicode("dd MMMM, yyyy",buf);
    1403         if(!(*lpDateFmtEnumProc)(buf)) return TRUE;
    1404         return TRUE;
    1405       default:
    1406         //FIXME_(ole)("Unknown date format (%ld)\n", dwFlags);
    1407         SetLastError(ERROR_INVALID_PARAMETER);
    1408         return FALSE;
    1409     }
    1410 }
    1411 
Note: See TracChangeset for help on using the changeset viewer.