msvcrt: Correct behavior of strftime formats %c %x.
Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
21a2fde621
commit
8bee5d85d8
|
@ -627,13 +627,13 @@ static void test_strftime(void)
|
||||||
} tests[] = {
|
} tests[] = {
|
||||||
{"e%#%e", "e%e", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"e%#%e", "e%e", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%c", "01/01/70 00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"%c", "01/01/70 00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%c", "02/30/70 00:00:00", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE},
|
{"%c", "02/30/70 00:00:00", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }},
|
||||||
{"%#c", "Thursday, January 01, 1970 00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"%#c", "Thursday, January 01, 1970 00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%#c", "Thursday, February 30, 1970 00:00:00", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE},
|
{"%#c", "Thursday, February 30, 1970 00:00:00", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }},
|
||||||
{"%x", "01/01/70", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"%x", "01/01/70", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%x", "02/30/70", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE},
|
{"%x", "02/30/70", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }},
|
||||||
{"%#x", "Thursday, January 01, 1970", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"%#x", "Thursday, January 01, 1970", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%#x", "Thursday, February 30, 1970", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE},
|
{"%#x", "Thursday, February 30, 1970", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }},
|
||||||
{"%X", "00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"%X", "00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%X", "14:00:00", { 0, 0, 14, 1, 0, 70, 4, 0, 0 }},
|
{"%X", "14:00:00", { 0, 0, 14, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%a", "Thu", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"%a", "Thu", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
|
@ -666,7 +666,7 @@ static void test_strftime(void)
|
||||||
BOOL todo;
|
BOOL todo;
|
||||||
} tests_td[] = {
|
} tests_td[] = {
|
||||||
{ "%c", "x z", "x", "y", "z", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%c", "x z", "x", "y", "z", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#c", "y z", "x", "y", "z", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#c", "y z", "x", "y", "z", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%X", "m1", 0, 0, "MMM", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%X", "m1", 0, 0, "MMM", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }, TRUE},
|
||||||
{ "%X", "1", 0, 0, "h", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }},
|
{ "%X", "1", 0, 0, "h", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%X", "01", 0, 0, "hh", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }},
|
{ "%X", "01", 0, 0, "hh", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }},
|
||||||
|
@ -687,35 +687,35 @@ static void test_strftime(void)
|
||||||
{ "%X", "tam", 0, 0, "AAAAA", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%X", "tam", 0, 0, "AAAAA", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
||||||
{ "%x", "1", "d", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "1", "d", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "01", "dd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "01", "dd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "d1", "ddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "d1", "ddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "day1", "dddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "day1", "dddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "dday1", "ddddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "dday1", "ddddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "1", "M", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "1", "M", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "01", "MM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "01", "MM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "m1", "MMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "m1", "MMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "mon1", "MMMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "mon1", "MMMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "Mmon1", "MMMMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "Mmon1", "MMMMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "y", "y", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "y", "y", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "70", "yy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "70", "yy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "y70", "yyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "y70", "yyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "1970", "yyyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "1970", "yyyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "y1970", "yyyyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "y1970", "yyyyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "ggggggggggg", "ggggggggggg", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "ggggggggggg", "ggggggggggg", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "1", 0, "d", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "1", 0, "d", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "01", 0, "dd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "01", 0, "dd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "d1", 0, "ddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "d1", 0, "ddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "day1", 0, "dddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "day1", 0, "dddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "dday1", 0, "ddddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "dday1", 0, "ddddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "1", 0, "M", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "1", 0, "M", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "01", 0, "MM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "01", 0, "MM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "m1", 0, "MMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "m1", 0, "MMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "mon1", 0, "MMMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "mon1", 0, "MMMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "Mmon1", 0, "MMMMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "Mmon1", 0, "MMMMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "y", 0, "y", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "y", 0, "y", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "70", 0, "yy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "70", 0, "yy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "y70", 0, "yyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "y70", 0, "yyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "1970", 0, "yyyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "1970", 0, "yyyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "y1970", 0, "yyyyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "y1970", 0, "yyyyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
};
|
};
|
||||||
|
|
||||||
__lc_time_data time_data = {
|
__lc_time_data time_data = {
|
||||||
|
|
|
@ -964,46 +964,6 @@ char ** CDECL __p__tzname(void)
|
||||||
#define STRFTIME_TD(td, name) td->wstr.names.name
|
#define STRFTIME_TD(td, name) td->wstr.names.name
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline BOOL strftime_date(STRFTIME_CHAR *str, MSVCRT_size_t *pos, MSVCRT_size_t max,
|
|
||||||
BOOL alternate, const struct MSVCRT_tm *mstm, MSVCRT___lc_time_data *time_data)
|
|
||||||
{
|
|
||||||
STRFTIME_CHAR *format;
|
|
||||||
SYSTEMTIME st;
|
|
||||||
MSVCRT_size_t ret;
|
|
||||||
LCID lcid;
|
|
||||||
|
|
||||||
st.wYear = mstm->tm_year + 1900;
|
|
||||||
st.wMonth = mstm->tm_mon + 1;
|
|
||||||
st.wDayOfWeek = mstm->tm_wday;
|
|
||||||
st.wDay = mstm->tm_mday;
|
|
||||||
st.wHour = mstm->tm_hour;
|
|
||||||
st.wMinute = mstm->tm_min;
|
|
||||||
st.wSecond = mstm->tm_sec;
|
|
||||||
st.wMilliseconds = 0;
|
|
||||||
|
|
||||||
#if _MSVCR_VER < 110
|
|
||||||
lcid = time_data->lcid;
|
|
||||||
#else
|
|
||||||
lcid = LocaleNameToLCID(time_data->locname, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
format = alternate ? STRFTIME_TD(time_data, date) : STRFTIME_TD(time_data, short_date);
|
|
||||||
ret = STRFTIME_FUNC(GetDateFormat)(lcid, 0, &st, format, NULL, 0);
|
|
||||||
if(ret && ret<max-*pos)
|
|
||||||
ret = STRFTIME_FUNC(GetDateFormat)(lcid, 0, &st, format, str+*pos, max-*pos);
|
|
||||||
if(!ret) {
|
|
||||||
*str = 0;
|
|
||||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
||||||
return FALSE;
|
|
||||||
}else if(ret > max-*pos) {
|
|
||||||
*str = 0;
|
|
||||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*pos += ret-1;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline BOOL strftime_time(STRFTIME_CHAR *str, MSVCRT_size_t *pos, MSVCRT_size_t max,
|
static inline BOOL strftime_time(STRFTIME_CHAR *str, MSVCRT_size_t *pos, MSVCRT_size_t max,
|
||||||
const struct MSVCRT_tm *mstm, MSVCRT___lc_time_data *time_data)
|
const struct MSVCRT_tm *mstm, MSVCRT___lc_time_data *time_data)
|
||||||
{
|
{
|
||||||
|
@ -1043,10 +1003,11 @@ static inline BOOL strftime_time(STRFTIME_CHAR *str, MSVCRT_size_t *pos, MSVCRT_
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL strftime_str(STRFTIME_CHAR *str, MSVCRT_size_t *pos,
|
#define strftime_str(a,b,c,d) strftime_nstr(a,b,c,d,MSVCRT_SIZE_MAX)
|
||||||
MSVCRT_size_t max, STRFTIME_CHAR *src)
|
static inline BOOL strftime_nstr(STRFTIME_CHAR *str, MSVCRT_size_t *pos,
|
||||||
|
MSVCRT_size_t max, const STRFTIME_CHAR *src, MSVCRT_size_t len)
|
||||||
{
|
{
|
||||||
while(*src)
|
while(*src && len)
|
||||||
{
|
{
|
||||||
if(*pos >= max) {
|
if(*pos >= max) {
|
||||||
*str = 0;
|
*str = 0;
|
||||||
|
@ -1057,6 +1018,7 @@ static inline BOOL strftime_str(STRFTIME_CHAR *str, MSVCRT_size_t *pos,
|
||||||
str[*pos] = *src;
|
str[*pos] = *src;
|
||||||
src++;
|
src++;
|
||||||
*pos += 1;
|
*pos += 1;
|
||||||
|
len--;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1090,6 +1052,102 @@ static inline BOOL strftime_int(STRFTIME_CHAR *str, MSVCRT_size_t *pos, MSVCRT_s
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline BOOL strftime_format(STRFTIME_CHAR *str, MSVCRT_size_t *pos, MSVCRT_size_t max,
|
||||||
|
const struct MSVCRT_tm *mstm, MSVCRT___lc_time_data *time_data, const STRFTIME_CHAR *format)
|
||||||
|
{
|
||||||
|
MSVCRT_size_t count;
|
||||||
|
BOOL ret = TRUE;
|
||||||
|
|
||||||
|
while(*format && ret)
|
||||||
|
{
|
||||||
|
count = 1;
|
||||||
|
while(format[0] == format[count]) count++;
|
||||||
|
|
||||||
|
switch(*format) {
|
||||||
|
case '\'':
|
||||||
|
if(count % 2 == 0) break;
|
||||||
|
|
||||||
|
format += count;
|
||||||
|
count = 0;
|
||||||
|
while(format[count] && format[count] != '\'') count++;
|
||||||
|
|
||||||
|
ret = strftime_nstr(str, pos, max, format, count);
|
||||||
|
if(!ret) return FALSE;
|
||||||
|
if(format[count] == '\'') count++;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
switch(count) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
ret = strftime_int(str, pos, max, mstm->tm_mday, count==1 ? 0 : 2, 0, 31);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
ret = strftime_str(str, pos, max, STRFTIME_TD(time_data, short_wday)[mstm->tm_wday]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = strftime_nstr(str, pos, max, format, count-4);
|
||||||
|
if(ret)
|
||||||
|
ret = strftime_str(str, pos, max, STRFTIME_TD(time_data, wday)[mstm->tm_wday]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
switch(count) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
ret = strftime_int(str, pos, max, mstm->tm_mon+1, count==1 ? 0 : 2, 1, 12);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
ret = strftime_str(str, pos, max, STRFTIME_TD(time_data, short_mon)[mstm->tm_mon]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = strftime_nstr(str, pos, max, format, count-4);
|
||||||
|
if(ret)
|
||||||
|
ret = strftime_str(str, pos, max, STRFTIME_TD(time_data, mon)[mstm->tm_mon]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'y':
|
||||||
|
if(count > 1)
|
||||||
|
{
|
||||||
|
#if _MSVCR_VER>=140
|
||||||
|
if(!MSVCRT_CHECK_PMT(mstm->tm_year >= -1900 && mstm->tm_year <= 8099))
|
||||||
|
#else
|
||||||
|
if(!MSVCRT_CHECK_PMT(mstm->tm_year >= 0))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
*str = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(count) {
|
||||||
|
case 1:
|
||||||
|
ret = strftime_nstr(str, pos, max, format, 1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
ret = strftime_nstr(str, pos, max, format, count-2);
|
||||||
|
if(ret)
|
||||||
|
ret = strftime_int(str, pos, max, (mstm->tm_year+1900)%100, 2, 0, 99);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = strftime_nstr(str, pos, max, format, count-4);
|
||||||
|
if(ret)
|
||||||
|
ret = strftime_int(str, pos, max, mstm->tm_year+1900, 4, 0, 9999);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = strftime_nstr(str, pos, max, format, count);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
format += count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static inline BOOL strftime_tzdiff(STRFTIME_CHAR *str, MSVCRT_size_t *pos, MSVCRT_size_t max, BOOL is_dst)
|
static inline BOOL strftime_tzdiff(STRFTIME_CHAR *str, MSVCRT_size_t *pos, MSVCRT_size_t max, BOOL is_dst)
|
||||||
{
|
{
|
||||||
MSVCRT_long tz = MSVCRT___timezone + (is_dst ? MSVCRT__dstbias : 0);
|
MSVCRT_long tz = MSVCRT___timezone + (is_dst ? MSVCRT__dstbias : 0);
|
||||||
|
@ -1151,7 +1209,8 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max,
|
||||||
|
|
||||||
switch(*format) {
|
switch(*format) {
|
||||||
case 'c':
|
case 'c':
|
||||||
if(!strftime_date(str, &ret, max, alternate, mstm, time_data))
|
if(!strftime_format(str, &ret, max, mstm, time_data,
|
||||||
|
alternate ? STRFTIME_TD(time_data, date) : STRFTIME_TD(time_data, short_date)))
|
||||||
return 0;
|
return 0;
|
||||||
if(ret < max)
|
if(ret < max)
|
||||||
str[ret++] = ' ';
|
str[ret++] = ' ';
|
||||||
|
@ -1159,7 +1218,8 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max,
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
if(!strftime_date(str, &ret, max, alternate, mstm, time_data))
|
if(!strftime_format(str, &ret, max, mstm, time_data,
|
||||||
|
alternate ? STRFTIME_TD(time_data, date) : STRFTIME_TD(time_data, short_date)))
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
|
|
|
@ -964,11 +964,11 @@ static void test_strftime(void)
|
||||||
{"%c", "Thu Jan 1 00:00:00 1970", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }, TRUE},
|
{"%c", "Thu Jan 1 00:00:00 1970", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }, TRUE},
|
||||||
{"%c", "Thu Feb 30 00:00:00 1970", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE},
|
{"%c", "Thu Feb 30 00:00:00 1970", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE},
|
||||||
{"%#c", "Thursday, January 01, 1970 00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"%#c", "Thursday, January 01, 1970 00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%#c", "Thursday, February 30, 1970 00:00:00", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE},
|
{"%#c", "Thursday, February 30, 1970 00:00:00", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }},
|
||||||
{"%x", "01/01/70", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"%x", "01/01/70", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%x", "02/30/70", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE},
|
{"%x", "02/30/70", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }},
|
||||||
{"%#x", "Thursday, January 01, 1970", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"%#x", "Thursday, January 01, 1970", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%#x", "Thursday, February 30, 1970", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE},
|
{"%#x", "Thursday, February 30, 1970", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }},
|
||||||
{"%X", "00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
{"%X", "00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%X", "14:00:00", { 0, 0, 14, 1, 0, 70, 4, 0, 0 }},
|
{"%X", "14:00:00", { 0, 0, 14, 1, 0, 70, 4, 0, 0 }},
|
||||||
{"%X", "23:59:60", { 60, 59, 23, 1, 0, 70, 4, 0, 0 }, TRUE},
|
{"%X", "23:59:60", { 60, 59, 23, 1, 0, 70, 4, 0, 0 }, TRUE},
|
||||||
|
@ -984,7 +984,7 @@ static void test_strftime(void)
|
||||||
BOOL todo;
|
BOOL todo;
|
||||||
} tests_td[] = {
|
} tests_td[] = {
|
||||||
{ "%c", "x z", L"x", L"y", L"z", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%c", "x z", L"x", L"y", L"z", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#c", "y z", L"x", L"y", L"z", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#c", "y z", L"x", L"y", L"z", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%X", "M1", 0, 0, L"MMM", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%X", "M1", 0, 0, L"MMM", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }, TRUE},
|
||||||
{ "%X", "1", 0, 0, L"h", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }},
|
{ "%X", "1", 0, 0, L"h", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%X", "01", 0, 0, L"hh", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }},
|
{ "%X", "01", 0, 0, L"hh", { 0, 0, 1, 1, 0, 70, 0, 0, 0 }},
|
||||||
|
@ -1005,35 +1005,35 @@ static void test_strftime(void)
|
||||||
{ "%X", "TAM", 0, 0, L"AAAAA", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%X", "TAM", 0, 0, L"AAAAA", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
||||||
{ "%x", "1", L"d", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "1", L"d", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "01", L"dd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "01", L"dd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "D1", L"ddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "D1", L"ddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "Day1", L"dddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "Day1", L"dddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "dDay1", L"ddddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "dDay1", L"ddddd", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "1", L"M", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "1", L"M", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "01", L"MM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "01", L"MM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "M1", L"MMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "M1", L"MMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "Mon1", L"MMMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "Mon1", L"MMMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "MMon1", L"MMMMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "MMon1", L"MMMMM", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "y", L"y", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "y", L"y", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "70", L"yy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "70", L"yy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "y70", L"yyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "y70", L"yyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "1970", L"yyyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%x", "1970", L"yyyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "y1970", L"yyyyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "y1970", L"yyyyy", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%x", "ggggggggggg", L"ggggggggggg", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%x", "ggggggggggg", L"ggggggggggg", 0, 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "1", 0, L"d", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "1", 0, L"d", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "01", 0, L"dd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "01", 0, L"dd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "D1", 0, L"ddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "D1", 0, L"ddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "Day1", 0, L"dddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "Day1", 0, L"dddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "dDay1", 0, L"ddddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "dDay1", 0, L"ddddd", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "1", 0, L"M", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "1", 0, L"M", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "01", 0, L"MM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "01", 0, L"MM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "M1", 0, L"MMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "M1", 0, L"MMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "Mon1", 0, L"MMMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "Mon1", 0, L"MMMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "MMon1", 0, L"MMMMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "MMon1", 0, L"MMMMM", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "y", 0, L"y", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "y", 0, L"y", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "70", 0, L"yy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "70", 0, L"yy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "y70", 0, L"yyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "y70", 0, L"yyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "1970", 0, L"yyyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
{ "%#x", "1970", 0, L"yyyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
{ "%#x", "y1970", 0, L"yyyyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }, TRUE},
|
{ "%#x", "y1970", 0, L"yyyyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||||
};
|
};
|
||||||
|
|
||||||
__lc_time_data time_data = {
|
__lc_time_data time_data = {
|
||||||
|
|
Loading…
Reference in New Issue