-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from marc-hughes/main
Fixed bug when specifying January dates
- Loading branch information
Showing
2 changed files
with
27 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,39 @@ | ||
import "jest" | ||
import { DateWithoutTime } from "./DateWithoutTime" | ||
import "jest"; | ||
import { DateWithoutTime } from "./DateWithoutTime"; | ||
|
||
describe("DateWithoutTime", () => { | ||
// Date constructor | ||
it("yyyy-MM-dd should be a midnight UTC date object", () => { | ||
const myDate = new DateWithoutTime("1963-11-22"); | ||
expect(myDate.getDate()).toBe(22); | ||
}) | ||
expect(myDate.getMonth()).toBe(10); | ||
expect(myDate.getFullYear()).toBe(1963); | ||
}); | ||
|
||
it("ISO midnight without timezone should be a midnight UTC date object", () => { | ||
const myDate = new DateWithoutTime("1963-11-22T00:00:00"); | ||
expect(myDate.getDate()).toBe(22); | ||
}) | ||
expect(myDate.getMonth()).toBe(10); | ||
expect(myDate.getFullYear()).toBe(1963); | ||
}); | ||
|
||
it("ISO string without timezone: a time close to midnight in America, after midnight in Greenwich, should take the local day",()=>{ | ||
it("ISO string without timezone: a time close to midnight in America, after midnight in Greenwich, should take the local day", () => { | ||
const myDate = new DateWithoutTime("2022-08-09T23:00:00"); | ||
expect(myDate.getDate()).toBe(9); | ||
}) | ||
it("Date from integers: a time close to midnight in America, after midnight in Greenwich, should take the local day",()=>{ | ||
const myDate = new DateWithoutTime(2022,7,9); | ||
expect(myDate.getMonth()).toBe(7); | ||
expect(myDate.getFullYear()).toBe(2022); | ||
}); | ||
it("Date from integers: a time close to midnight in America, after midnight in Greenwich, should take the local day", () => { | ||
const myDate = new DateWithoutTime(2022, 7, 9); | ||
expect(myDate.getDate()).toBe(9); | ||
}) | ||
}) | ||
expect(myDate.getMonth()).toBe(7); | ||
expect(myDate.getFullYear()).toBe(2022); | ||
}); | ||
|
||
it("Date from integers: a january date", () => { | ||
const myDate = new DateWithoutTime(2024, 0, 9); | ||
expect(myDate.getDate()).toBe(9); | ||
expect(myDate.getMonth()).toBe(0); | ||
expect(myDate.getFullYear()).toBe(2024); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters