8000 feat: display quiet hours using 24-hour time format by mtojek · Pull Request #17016 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: display quiet hours using 24-hour time format #17016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions site/src/utils/schedule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,38 @@ describe("util/schedule", () => {
});

describe("quietHoursDisplay", () => {
const quietHoursStart = quietHoursDisplay(
"00:00",
"Australia/Sydney",
new Date("2023-09-06T15:00:00.000+10:00"),
);
it("midnight", () => {
const quietHoursStart = quietHoursDisplay(
"00:00",
"Australia/Sydney",
new Date("2023-09-06T15:00:00.000+10:00"),
);

expect(quietHoursStart).toBe(
"00:00 tomorrow (in 9 hours) in Australia/Sydney",
);
});
it("five o'clock today", () => {
const quietHoursStart = quietHoursDisplay(
"17:00",
"Europe/London",
new Date("2023-09-06T15:00:00.000+10:00"),
);

expect(quietHoursStart).toBe(
"12:00AM tomorrow (in 9 hours) in Australia/Sydney",
);
expect(quietHoursStart).toBe(
"17:00 today (in 11 hours) in Europe/London",
);
});
it("lunch tomorrow", () => {
const quietHoursStart = quietHoursDisplay(
"13:00",
"US/Central",
new Date("2023-09-06T08:00:00.000+10:00"),
);

expect(quietHoursStart).toBe(
"13:00 tomorrow (in 20 hours) in US/Central",
);
});
});
});
2 changes: 1 addition & 1 deletion site/src/utils/schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export const quietHoursDisplay = (

const today = dayjs(now).tz(tz);
const day = dayjs(parsed.next().toDate()).tz(tz);
let display = day.format("h:mmA");
let display = day.format("HH:mm");

if (day.isSame(today, "day")) {
display += " today";
Expand Down
Loading
0