mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:17:35 +00:00
LibJS: Account for differences in month representations (0-11 vs 1-12)
Since DateTime stores months as 1 to 12, while JS accepts months as 0 to 11, we have to account for the difference (by subtracting or adding 1) where appropriate.
This commit is contained in:
parent
b893963651
commit
59034554a4
2 changed files with 6 additions and 6 deletions
|
@ -40,7 +40,7 @@ test("Year and month as arguments", () => {
|
|||
|
||||
date.setFullYear(2021, 3);
|
||||
expect(date.getFullYear()).toBe(2021);
|
||||
expect(date.getMonth()).toBe(2);
|
||||
expect(date.getMonth()).toBe(3);
|
||||
expect(date.getDate()).toBe(1);
|
||||
expect(date.getHours()).toBe(0);
|
||||
expect(date.getMinutes()).toBe(0);
|
||||
|
@ -53,7 +53,7 @@ test("Year, month, and day as arguments", () => {
|
|||
|
||||
date.setFullYear(2021, 3, 16);
|
||||
expect(date.getFullYear()).toBe(2021);
|
||||
expect(date.getMonth()).toBe(2);
|
||||
expect(date.getMonth()).toBe(3);
|
||||
expect(date.getDate()).toBe(16);
|
||||
expect(date.getHours()).toBe(0);
|
||||
expect(date.getMinutes()).toBe(0);
|
||||
|
@ -88,7 +88,7 @@ test("NaN or undefined in any arguments", () => {
|
|||
|
||||
date.setFullYear(2021, 3, 16);
|
||||
expect(date.getFullYear()).toBe(2021);
|
||||
expect(date.getMonth()).toBe(2);
|
||||
expect(date.getMonth()).toBe(3);
|
||||
expect(date.getDate()).toBe(16);
|
||||
expect(date.getHours()).toBe(0);
|
||||
expect(date.getMinutes()).toBe(0);
|
||||
|
@ -103,7 +103,7 @@ test("Make Invalid Date valid again", () => {
|
|||
|
||||
date.setFullYear(2021, 3, 16);
|
||||
expect(date.getFullYear()).toBe(2021);
|
||||
expect(date.getMonth()).toBe(2);
|
||||
expect(date.getMonth()).toBe(3);
|
||||
expect(date.getDate()).toBe(16);
|
||||
expect(date.getHours()).toBe(0);
|
||||
expect(date.getMinutes()).toBe(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue