fix date range formatting in date pills

This commit is contained in:
2024-08-09 18:55:48 +02:00
parent e96ec17c42
commit 85b0ad712e

View File

@ -68,7 +68,9 @@ export function isConsecutiveDays(a: Date, b: Date): boolean {
export function groupConsecutiveDates(dates: string[]): string[][] {
const groupedDates: string[][] = [];
const uniqueDays = unique(dates.map(date => format(startOfDay(toLocalTime(date)), 'yyyy-MM-dd')))
const uniqueDays = unique(
dates.map((date) => format(startOfDay(toLocalTime(date)), "yyyy-MM-dd"))
).sort();
let group: string[] = [];
for (let i = 0; i < uniqueDays.length; i++) {
@ -101,7 +103,7 @@ export function formatDateRange(dates: string[]): string {
if (firstDate.getMonth() === lastDate.getMonth()) {
// same month
return `${firstDate.getDay()}.—${lastDate.getDay()}. ${formatDate(
return `${firstDate.getDate()}.—${lastDate.getDate()}. ${formatDate(
firstDate,
"MMMM"
)}`;