change news article date formatting
This commit is contained in:
@ -24,15 +24,18 @@ export function formatYearMonth(yearMonth: string) {
|
||||
return formatDate(parsed, "MMMM yyyy");
|
||||
}
|
||||
|
||||
export function formatExtendedDateTime(date: Date | string | number, dateOnly: boolean = false) {
|
||||
export function formatExtendedDateTime(
|
||||
date: Date | string | number,
|
||||
dateOnly: boolean = false,
|
||||
alwaysIncludeYear: 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}`);
|
||||
const isCurrentYear = parsed.getFullYear === new Date().getFullYear;
|
||||
const yearPart = isCurrentYear && !alwaysIncludeYear ? "" : " yyyy";
|
||||
return formatDate(parsed, `EEEE d. MMMM${yearPart}${timePart}`);
|
||||
}
|
||||
|
||||
export function isTodayOrFuture(
|
||||
|
Reference in New Issue
Block a user