webservices: Fix use of month as array index.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2017-02-15 14:17:09 +01:00 committed by Alexandre Julliard
parent ef6e838298
commit aaab5410a1
2 changed files with 6 additions and 3 deletions

View File

@ -2716,6 +2716,10 @@ static void test_datetime(void)
{ 0x701ce51ced5d800, WS_DATETIME_FORMAT_LOCAL, S_OK, "<t>1601-01-01T07:00:00+00:00</t>",
"<t>1601-01-01T01:00:00-06:00</t>" /* win7 */ },
{ 0, WS_DATETIME_FORMAT_NONE + 1, WS_E_INVALID_FORMAT },
{ 0x38a080649c000, WS_DATETIME_FORMAT_UTC, S_OK, "<t>0004-02-28T00:00:00Z</t>" },
{ 0x38ad130b38000, WS_DATETIME_FORMAT_UTC, S_OK, "<t>0004-02-29T00:00:00Z</t>" },
{ 0x8c1505f0e438000, WS_DATETIME_FORMAT_UTC, S_OK, "<t>2000-02-29T00:00:00Z</t>" },
{ 0x8d46035e7870000, WS_DATETIME_FORMAT_UTC, S_OK, "<t>2017-03-01T00:00:00Z</t>" },
};
HRESULT hr;
WS_XML_WRITER *writer;

View File

@ -1203,7 +1203,7 @@ static inline int year_size( int year )
static ULONG format_datetime( const WS_DATETIME *ptr, unsigned char *buf )
{
static const char fmt[] = "%04u-%02u-%02uT%02u:%02u:%02u";
int day, hour, min, sec, sec_frac, month = 1, year = 1, tz_hour;
int day, hour, min, sec, sec_frac, month = 0, year = 1, tz_hour;
unsigned __int64 ticks, day_ticks;
ULONG len;
@ -1235,9 +1235,8 @@ static ULONG format_datetime( const WS_DATETIME *ptr, unsigned char *buf )
day -= month_days[leap_year( year )][month];
month++;
}
day++;
len = sprintf( (char *)buf, fmt, year, month, day, hour, min, sec );
len = sprintf( (char *)buf, fmt, year, month + 1, day + 1, hour, min, sec );
if (sec_frac)
{
static const char fmt_frac[] = ".%07u";