type BookDayRule = | type: "fixed"; month: number; day: number; name: string | type: "floating"; month: number; weekday: number; occurrence: number; name: string ; // Example: first Thursday in March // occurrence: 1 = first, 2 = second, etc.
// Optional: get the name of the book day if true export function getBookDayName(date: Date = new Date()): string | null const month = date.getMonth() + 1; const day = date.getDate();
Then implement a helper to compute the actual date. test("isBookToday returns true on April 23", () => const april23 = new Date(2026, 3, 23); expect(isBookToday(april23)).toBe(true); );
const found = BOOK_DAYS.find(bookDay => bookDay.month === month && bookDay.day === day); return found ? found.name : null;
import isBookToday, getBookDayName from './book-days'; // Check today if (isBookToday()) console.log( Yes! Today is $getBookDayName(). ); else console.log("Not a recognized book day.");
type BookDayRule = | type: "fixed"; month: number; day: number; name: string | type: "floating"; month: number; weekday: number; occurrence: number; name: string ; // Example: first Thursday in March // occurrence: 1 = first, 2 = second, etc.
// Optional: get the name of the book day if true export function getBookDayName(date: Date = new Date()): string | null const month = date.getMonth() + 1; const day = date.getDate();
Then implement a helper to compute the actual date. test("isBookToday returns true on April 23", () => const april23 = new Date(2026, 3, 23); expect(isBookToday(april23)).toBe(true); );
const found = BOOK_DAYS.find(bookDay => bookDay.month === month && bookDay.day === day); return found ? found.name : null;
import isBookToday, getBookDayName from './book-days'; // Check today if (isBookToday()) console.log( Yes! Today is $getBookDayName(). ); else console.log("Not a recognized book day.");