Extensive UI changes
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 28s
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 28s
This commit is contained in:
parent
6fc0a01c56
commit
ddea7fc512
16 changed files with 675 additions and 493 deletions
22
shared/entry.js
Normal file
22
shared/entry.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/** @returns {'Breakfast' | 'Lunch' | 'Dinner' | 'Snacks'} */
|
||||
export function suggestedMeal(date = new Date()) {
|
||||
const hour = date.getHours();
|
||||
if (hour >= 5 && hour < 11) return "Breakfast";
|
||||
if (hour >= 11 && hour < 16) return "Lunch";
|
||||
if (hour >= 16 && hour < 22) return "Dinner";
|
||||
return "Snacks";
|
||||
}
|
||||
|
||||
export function localTime(date = new Date()) {
|
||||
return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
export function nextFoodName(prefix, names) {
|
||||
let highest = 0;
|
||||
for (const name of names) {
|
||||
if (!name.startsWith(prefix + " ")) continue;
|
||||
const suffix = name.slice(prefix.length + 1);
|
||||
if (/^\d+$/.test(suffix)) highest = Math.max(highest, Number(suffix));
|
||||
}
|
||||
return `${prefix} ${highest + 1}`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue