Skip to content

Commit 412002c

Browse files
feat(web): name the weekday on saved durations that land on another day
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent b35ff84 commit 412002c

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎apps/web/src/components/Sidebar.snooze.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ describe("resolveSnoozePresets", () => {
2727
expect(twoHours).toMatchObject({ label: "In 2 hours" });
2828
expect(new Date(twoHours!.snoozedUntil).getHours()).toBe(12);
2929
expect(twoHours!.whenLabel).not.toBe("");
30+
// Same-day wakes show only the time; a favorite on another day names it.
31+
const weekday = (preset: { snoozedUntil: string }) =>
32+
new Date(preset.snoozedUntil).toLocaleDateString(undefined, { weekday: "short" });
33+
const twoDays = presets.find((preset) => preset.id === "favorite:2-days");
34+
expect(twoHours!.whenLabel).not.toContain(weekday(twoHours!));
35+
expect(twoDays!.whenLabel.startsWith(weekday(twoDays!))).toBe(true);
3036
});
3137

3238
it("keeps wake times ascending when evening falls before three hours", () => {

‎apps/web/src/components/Sidebar.snooze.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ export function resolveSnoozePresets(
3030
const time = timeOfDayLabel(wake, timestampFormat);
3131
return {
3232
...preset,
33+
// A wake on another day names its weekday, so a saved duration such
34+
// as "26 hours" does not read as earlier than "Tomorrow".
3335
whenLabel:
34-
preset.id === "next-week"
36+
preset.id === "next-week" ||
37+
(preset.id.startsWith("favorite:") && wake.toDateString() !== now.toDateString())
3538
? `${wake.toLocaleDateString(undefined, { weekday: "short" })} ${time}`
3639
: time,
3740
};

0 commit comments

Comments
 (0)