profileShare

rasmusjy / tasteprint

Read-only snapshot

No repository description.

main default branch 169 files Expires Sep 13, 2026, 9:06 AM
format.ts 854 bytes
1 export function formatDate(value: string): string {
2 return new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short", year: "numeric" })
3 .format(new Date(`${value}T12:00:00`));
4 }
5
6 export function formatDateRange(start: string, end: string): string {
7 if (start === end) {
8 return formatDate(start);
9 }
10 const formatter = new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short" });
11 return `${formatter.format(new Date(`${start}T12:00:00`))} to ${formatter.format(new Date(`${end}T12:00:00`))}`;
12 }
13
14 export function initials(name: string): string {
15 return name.split(/\s+/).slice(0, 2).map(part => part[0]?.toUpperCase()).join("");
16 }
17
18 export function todayInput(): string {
19 const now = new Date();
20 const offset = now.getTimezoneOffset();
21 return new Date(now.getTime() - offset * 60_000).toISOString().slice(0, 10);
22 }
23