summaryrefslogtreecommitdiff
path: root/lib/utils.ts
blob: e70557aab14858144373aa4dceb4613c685da1a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 + ".";
}