30 lines
944 B
TypeScript
30 lines
944 B
TypeScript
import { formatBerlinDate, formatBerlinTime } from "@/lib/calendar/timezone";
|
||
|
||
/** Day + short month, e.g. { day: "15", month: "SEP" } — for the date badge on event cards. */
|
||
export function formatEventDateParts(iso: string) {
|
||
const date = new Date(iso);
|
||
return {
|
||
day: formatBerlinDate(date, { day: "2-digit" }),
|
||
month: formatBerlinDate(date, { month: "short" }).toUpperCase().replace(".", ""),
|
||
};
|
||
}
|
||
|
||
export function formatFullDate(iso: string) {
|
||
return formatBerlinDate(new Date(iso), {
|
||
weekday: "long",
|
||
day: "2-digit",
|
||
month: "long",
|
||
year: "numeric",
|
||
});
|
||
}
|
||
|
||
export function formatTime(iso: string) {
|
||
return formatBerlinTime(new Date(iso), { hour: "2-digit", minute: "2-digit" });
|
||
}
|
||
|
||
export function formatTimeRange(start?: string | null, end?: string | null) {
|
||
if (start && end) return `${formatTime(start)} – ${formatTime(end)} Uhr`;
|
||
if (start) return `${formatTime(start)} Uhr`;
|
||
return null;
|
||
}
|