jscript: Date.parse: make "UTC"/"GMT" optional before the timezone offset.

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Markus Heidelberg 2016-05-21 12:41:40 +02:00 committed by Alexandre Julliard
parent 7b5c0e7a30
commit 74257d5940
2 changed files with 26 additions and 16 deletions

View File

@ -2174,6 +2174,28 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
year = tmp;
}
}
else if(parse[i]=='+' || parse[i]=='-') {
/* Timezone offset */
BOOL positive = TRUE;
if(set_offset && set_hour_adjust) break;
set_offset = TRUE;
set_hour_adjust = FALSE;
if(parse[i] == '-') positive = FALSE;
i++;
while(isspaceW(parse[i])) i++;
if(parse[i]<'0' || parse[i]>'9') break;
offset = atoiW(&parse[i]);
while(parse[i]>='0' && parse[i]<='9') i++;
if(offset<24) offset *= 60;
else offset = (offset/100)*60 + offset%100;
if(positive) offset = -offset;
}
else {
if(parse[i]<'A' || parse[i]>'Z') break;
else if(parse[i]=='B' && (parse[i+1]=='C' ||
@ -2230,27 +2252,11 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
else if((parse[i]=='U' && parse[i+1]=='T' && parse[i+2]=='C')
|| (parse[i]=='G' && parse[i+1]=='M' && parse[i+2]=='T')) {
/* Timezone */
BOOL positive = TRUE;
if(set_offset) break;
set_offset = TRUE;
set_hour_adjust = FALSE;
i += 3;
while(isspaceW(parse[i])) i++;
if(parse[i] == '-') positive = FALSE;
else if(parse[i] != '+') continue;
i++;
while(isspaceW(parse[i])) i++;
if(parse[i]<'0' || parse[i]>'9') break;
offset = atoiW(&parse[i]);
while(parse[i]>='0' && parse[i]<='9') i++;
if(offset<24) offset *= 60;
else offset = (offset/100)*60 + offset%100;
if(positive) offset = -offset;
}
else {
/* Month or garbage */

View File

@ -2108,6 +2108,10 @@ ok(Date.parse("71 11:32AM Dec 12 UTC BC ") === -64346358480000, "Date.parse(\"71
ok(Date.parse("23/71/2000 11::32::UTC") === 1010662320000, "Date.parse(\"23/71/2000 11::32::UTC\") = " + Date.parse("23/71/2000 11::32::UTC"));
ok(Date.parse("1970/01/01") === Date.parse("01/01/1970"), "Date.parse(\"1970/01/01\") = " + Date.parse("1970/01/01"));
ok(Date.parse("71/12/14") === Date.parse("12/14/1971"), "Date.parse(\"71/12/14\") = " + Date.parse("71/12/14"));
ok(Date.parse("Tue, 22 Mar 2016 09:57:55 -0300") === Date.parse("Tue, 22 Mar 2016 09:57:55 GMT-0300"),
"Date.parse(\"Tue, 22 Mar 2016 09:57:55 -0300\") = " + Date.parse("Tue, 22 Mar 2016 09:57:55 -0300"));
ok(Date.parse("Tue, 22 Mar 2016 09:57:55 +0400") === Date.parse("Tue, 22 Mar 2016 09:57:55 UTC+0400"),
"Date.parse(\"Tue, 22 Mar 2016 09:57:55 +0400\") = " + Date.parse("Tue, 22 Mar 2016 09:57:55 +0400"));
ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);