Fix fix-js-get-string
AM/PM computation for Date.prototype.toLocaleString
(#355)
- Fix AM/PM computation for Date.prototype.toLocalString: 11:00 and 23:00 used to convert to -1:00
This commit is contained in:
parent
d61988211c
commit
b8a2cf40d8
2 changed files with 9 additions and 1 deletions
|
@ -47444,7 +47444,7 @@ static JSValue get_date_string(JSContext *ctx, JSValue this_val,
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
pos += snprintf(buf + pos, sizeof(buf) - pos,
|
pos += snprintf(buf + pos, sizeof(buf) - pos,
|
||||||
"%02d:%02d:%02d %cM", (h + 1) % 12 - 1, m, s,
|
"%02d:%02d:%02d %cM", (h + 11) % 12 + 1, m, s,
|
||||||
(h < 12) ? 'A' : 'P');
|
(h < 12) ? 'A' : 'P');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -697,6 +697,14 @@ function test_date()
|
||||||
assert(Date.UTC(2017, 9, 22, 18 - 1e10, 10 + 60e10), 1508695800000);
|
assert(Date.UTC(2017, 9, 22, 18 - 1e10, 10 + 60e10), 1508695800000);
|
||||||
assert(Date.UTC(2017, 9, 22, 18, 10 - 1e10, 11 + 60e10), 1508695811000);
|
assert(Date.UTC(2017, 9, 22, 18, 10 - 1e10, 11 + 60e10), 1508695811000);
|
||||||
assert(Date.UTC(2017, 9, 22, 18, 10, 11 - 1e12, 91 + 1000e12), 1508695811091);
|
assert(Date.UTC(2017, 9, 22, 18, 10, 11 - 1e12, 91 + 1000e12), 1508695811091);
|
||||||
|
assert(new Date("2024 Apr 7 1:00 AM").toLocaleString(), "04/07/2024, 01:00:00 AM");
|
||||||
|
assert(new Date("2024 Apr 7 2:00 AM").toLocaleString(), "04/07/2024, 02:00:00 AM");
|
||||||
|
assert(new Date("2024 Apr 7 11:00 AM").toLocaleString(), "04/07/2024, 11:00:00 AM");
|
||||||
|
assert(new Date("2024 Apr 7 12:00 AM").toLocaleString(), "04/07/2024, 12:00:00 AM");
|
||||||
|
assert(new Date("2024 Apr 7 1:00 PM").toLocaleString(), "04/07/2024, 01:00:00 PM");
|
||||||
|
assert(new Date("2024 Apr 7 2:00 PM").toLocaleString(), "04/07/2024, 02:00:00 PM");
|
||||||
|
assert(new Date("2024 Apr 7 11:00 PM").toLocaleString(), "04/07/2024, 11:00:00 PM");
|
||||||
|
assert(new Date("2024 Apr 7 12:00 PM").toLocaleString(), "04/07/2024, 12:00:00 PM");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_regexp()
|
function test_regexp()
|
||||||
|
|
Loading…
Reference in a new issue