1import type {2 PuzzleHistoryEntry,3 PuzzleProgress,4} from "@/lib/shikaku/types.ts";56export function dateToSlug(date: Date): string {7 const year = date.getFullYear();8 const month = String(date.getMonth() + 1).padStart(2, "0");9 const day = String(date.getDate()).padStart(2, "0");10 return `${year}-${month}-${day}`;11}1213export function isPastDate(candidate: string, today: string): boolean {14 return candidate < today;15}1617export function rolloverExpiredProgress(18 progress: PuzzleProgress,19 today: string,20): PuzzleHistoryEntry | null {21 if (progress.status !== "in_progress") return null;22 if (!isPastDate(progress.date, today)) return null;2324 return {25 date: progress.date,26 puzzleId: progress.puzzleId,27 status: "expired_unsolved",28 mistakes: progress.mistakes,29 };30}