From d4489f24a05911d1395e8473fe86c3442d9397ee Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Feb 2026 12:22:03 +0000 Subject: fix(study): use date-based comparison with 3 AM boundary for due cards Instead of comparing due timestamps exactly (card.due <= now), compare against the next 3 AM boundary so all cards due within the current study day appear at once. This prevents new cards from trickling in throughout the day when FSRS fuzz spreads due times. https://claude.ai/code/session_01FeDztLcyGofd6nxh8ct7a3 --- src/shared/date.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/shared/date.ts (limited to 'src/shared/date.ts') diff --git a/src/shared/date.ts b/src/shared/date.ts new file mode 100644 index 0000000..583d2a6 --- /dev/null +++ b/src/shared/date.ts @@ -0,0 +1,21 @@ +/** + * Returns the end-of-day boundary for due card comparison. + * + * The "study day" is defined as 3:00 AM to the next day's 3:00 AM. + * All cards with `due < boundary` are considered due for the current study day. + * + * - If current time >= 3:00 AM, boundary = tomorrow 3:00 AM local time + * - If current time < 3:00 AM, boundary = today 3:00 AM local time + */ +export function getEndOfStudyDayBoundary(now: Date = new Date()): Date { + const boundary = new Date(now); + boundary.setMinutes(0, 0, 0); + + if (boundary.getHours() >= 3) { + // Move to next day + boundary.setDate(boundary.getDate() + 1); + } + + boundary.setHours(3); + return boundary; +} -- cgit v1.3-1-g0d28