mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
LibJS: Add "Month dd, yy hh:mm:ss" Date format
Required by Discord's Birthday page.
This commit is contained in:
parent
e038901555
commit
78db4e683f
2 changed files with 22 additions and 1 deletions
|
@ -100,3 +100,22 @@ test("yy{/,-}mm{/,-}dd hh:mm extension", () => {
|
|||
expectStringToGiveDate("2014/11/14 13:05", 2014, 11, 14, 13, 5);
|
||||
expectStringToGiveDate("2014-11-14 13:05", 2014, 11, 14, 13, 5);
|
||||
});
|
||||
|
||||
test("Month dd, yy hh:mm:ss extension", () => {
|
||||
function expectStringToGiveDate(input, fullYear, month, dayInMonth, hours, minutes, seconds) {
|
||||
// Since the timezone is not specified we just say it has to equal the date parts.
|
||||
const date = new Date(Date.parse(input));
|
||||
expect(date.getFullYear()).toBe(fullYear);
|
||||
expect(date.getMonth() + 1).toBe(month);
|
||||
expect(date.getDate()).toBe(dayInMonth);
|
||||
expect(date.getHours()).toBe(hours);
|
||||
expect(date.getMinutes()).toBe(minutes);
|
||||
expect(date.getSeconds()).toBe(seconds);
|
||||
}
|
||||
|
||||
// Examples from Discord's Birthday JavaScript for May 2023.
|
||||
expectStringToGiveDate("May 15, 2023 17:00:00", 2023, 5, 15, 17, 0, 0);
|
||||
expectStringToGiveDate("May 22, 2023 17:00:00", 2023, 5, 22, 17, 0, 0);
|
||||
expectStringToGiveDate("May 30, 2023 17:00:00", 2023, 5, 30, 17, 0, 0);
|
||||
expectStringToGiveDate("June 5, 2023 17:00:00", 2023, 6, 5, 17, 0, 0);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue