Skip to content

Commit

Permalink
Format midnight as 00:00
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnocorp committed Jul 9, 2022
1 parent ffa4314 commit 1267a8a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/date/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var dateFormat = new Intl.DateTimeFormat("en-US", {
timeZone: "UTC",
});

var timeFormat = new Intl.DateTimeFormat("en-US", {
var timeFormat = new Intl.DateTimeFormat("en-GB", {
hour12: false,
hour: "numeric",
minute: "numeric",
Expand Down
12 changes: 12 additions & 0 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ describe("UTCDate", () => {
);
});

it("formats midnight as 00:00", () => {
expect(new UTCDate(1987, 1, 11).toString()).toBe(
"Wed Feb 11 1987 00:00:00 GMT+0000 (Coordinated Universal Time)"
);
});

it("works with Symbol.toPrimitive", () => {
expect(
new UTCDate(1987, 1, 11, 12, 13, 14, 15)[Symbol.toPrimitive]("string")
Expand All @@ -148,6 +154,12 @@ describe("UTCDate", () => {
"12:13:14 GMT+0000 (Coordinated Universal Time)"
);
});

it("formats midnight as 00:00", () => {
expect(new UTCDate(1987, 1, 11).toTimeString()).toBe(
"00:00:00 GMT+0000 (Coordinated Universal Time)"
);
});
});

describe("toLocaleString", () => {
Expand Down

0 comments on commit 1267a8a

Please sign in to comment.