change some event datetime formatting
This commit is contained in:
@ -4,8 +4,8 @@ import { toZonedTime, format } from "date-fns-tz";
|
||||
|
||||
const timeZone = "Europe/Oslo";
|
||||
|
||||
export const commonDateTimeFormat = "dd.MM.yyyy 'kl.' HH:mm";
|
||||
export const commonDateFormat = "dd.MM.yyyy";
|
||||
export const compactDateTimeFormat = "dd.MM.yyyy 'kl.' HH:mm";
|
||||
export const compactDateFormat = "dd.MM.yyyy";
|
||||
|
||||
export function toLocalTime(date: Date | string | number) {
|
||||
return toZonedTime(date, timeZone);
|
||||
@ -24,6 +24,17 @@ export function formatYearMonth(yearMonth: string) {
|
||||
return formatDate(parsed, "MMMM yyyy");
|
||||
}
|
||||
|
||||
export function formatExtendedDateTime(date: Date | string | number, dateOnly: boolean = false) {
|
||||
// wide date with weekday and month name
|
||||
// year included if not current year
|
||||
const parsed = toLocalTime(date);
|
||||
const timePart = dateOnly ? "" : " 'kl.' HH:mm";
|
||||
if (parsed.getFullYear === new Date().getFullYear) {
|
||||
return formatDate(parsed, `EEEE d. MMMM${timePart}`);
|
||||
}
|
||||
return formatDate(parsed, `EEEE d. MMMM yyyy${timePart}`);
|
||||
}
|
||||
|
||||
export function isTodayOrFuture(
|
||||
date: Date | string | number,
|
||||
timeZone = "UTC"
|
||||
|
Reference in New Issue
Block a user