penguin-new-tab/lib/utils.ts

22 lines
621 B
TypeScript
Raw Normal View History

2025-01-06 23:48:56 -08:00
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function greet(name: string, time: Date) {
const messages: [number, number, string][] = [
[0, 4, "🌕 Good night"],
[5, 11, "🌤️ Good morning"], //Store messages in an array
[12, 17, "🌷͙ Good afternoon"],
[18, 23, "🌕 Good night"],
];
const message = messages.find(
([start, end]) => time.getHours() >= start && time.getHours() <= end
);
return (message ? message[2] : "Hello") + ", " + name + ".";
}