● Zion Boggan
repos/Stepping App/apps/web/src/lib/format.ts
zionboggan.com ↗
27 lines · typescript
History for this file →
1
const STATE_ZONE: Record<string, string> = {
2
  IL: "CT",
3
  TX: "CT",
4
  GA: "ET",
5
  MI: "ET",
6
  NC: "ET",
7
  DC: "ET",
8
};
9
 
10
export function cityTimeZone(state: string | null | undefined): string {
11
  return STATE_ZONE[state ?? ""] ?? "CT";
12
}
13
 
14
export function fmtEventTime(d: Date | null, zoneLabel: string): string {
15
  if (!d) return "DATE TBD";
16
  const base = new Date(d)
17
    .toLocaleString("en-US", {
18
      weekday: "short",
19
      month: "short",
20
      day: "numeric",
21
      hour: "numeric",
22
      minute: "2-digit",
23
      timeZone: "UTC",
24
    })
25
    .toUpperCase();
26
  return `${base} ${zoneLabel}`;
27
}