Add Phase 1 Pocket Pascal UI: home, pantry, week plan, and plate.
Replace the hello-world shell with the elevated design system, bilingual screens, recipe/extras data, and the interactive Mein Teller view. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
36
client/src/lib/timeContext.ts
Normal file
36
client/src/lib/timeContext.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { MealType, TimeSlot } from "@/types/domain"
|
||||
|
||||
export interface TimeContext {
|
||||
slot: TimeSlot
|
||||
mealType: MealType
|
||||
hour: number
|
||||
minute: number
|
||||
}
|
||||
|
||||
/** Local-time meal context for the suggestion engine. */
|
||||
export function getTimeContext(date = new Date()): TimeContext {
|
||||
const hour = date.getHours()
|
||||
const minute = date.getMinutes()
|
||||
|
||||
if (hour >= 6 && hour < 11) {
|
||||
return { slot: "morning", mealType: "half", hour, minute }
|
||||
}
|
||||
if (hour >= 11 && hour < 15) {
|
||||
return { slot: "midday", mealType: "full", hour, minute }
|
||||
}
|
||||
if (hour >= 15 && hour < 18) {
|
||||
return { slot: "afternoon", mealType: "half", hour, minute }
|
||||
}
|
||||
if (hour >= 18 && hour < 22) {
|
||||
return { slot: "evening", mealType: "full", hour, minute }
|
||||
}
|
||||
|
||||
// Late night / early morning: lean snack context
|
||||
return { slot: "afternoon", mealType: "half", hour, minute }
|
||||
}
|
||||
|
||||
export function formatClock(hour: number, minute: number, lang: "de" | "en"): string {
|
||||
const hh = String(hour).padStart(2, "0")
|
||||
const mm = String(minute).padStart(2, "0")
|
||||
return lang === "de" ? `${hh}:${mm}` : `${hh}:${mm}`
|
||||
}
|
||||
Reference in New Issue
Block a user