Alignments offset text fix for Five

This commit is contained in:
Patrick Haßel 2025-02-28 08:44:59 +01:00
parent 5c3338fd9d
commit 9d12986720
2 changed files with 20 additions and 6 deletions

View File

@ -44,7 +44,7 @@
<div class="option"> <div class="option">
<button class="back" (click)="shiftAlignment(+1)">&larr;</button> <button class="back" (click)="shiftAlignment(+1)">&larr;</button>
{{ alignment.display }} {{ alignment.display }} {{ offset > 0 ? -offset : '' }}
<button class="next" (click)="shiftAlignment(-1)">&rarr;</button> <button class="next" (click)="shiftAlignment(-1)">&rarr;</button>
</div> </div>

View File

@ -38,12 +38,26 @@ export class Alignment {
} else if (offset === 1) { } else if (offset === 1) {
return "Letzte 5 Minuten"; return "Letzte 5 Minuten";
} }
const date = new Date();
date.setHours(date.getHours() - offset); const today = new Date();
if (offset < 7) { today.setMinutes(today.getMinutes() - today.getMinutes() % 5);
return `${formatDate(date, "EEEE", locale)}`;
const yesterday = new Date(today);
yesterday.setDate(yesterday.getDate() - 1);
const yesterday2 = new Date(today);
yesterday2.setDate(yesterday2.getDate() - 1);
const date = new Date(today);
date.setMinutes(date.getMinutes() - offset * 5);
if (date.getDay() === today.getDay()) {
return `${formatDate(date, "HH:mm", locale)}`;
} else if (date.getDay() === yesterday.getDay()) {
return `Gestern ${formatDate(date, "HH:mm", locale)}`;
} else if (date.getDay() === yesterday2.getDay()) {
return `Gestern ${formatDate(date, "HH:mm", locale)}`;
} }
return `${formatDate(date, "EE", locale)} ${formatDate(date, "dd.MM.yyyy", locale)}`; return `${formatDate(date, "EE", locale)} ${formatDate(date, "dd.MM.yyyy", locale)} ${formatDate(date, "HH:mm", locale)}`;
} }
static offsetTitleHour(offset: number, locale: string): string { static offsetTitleHour(offset: number, locale: string): string {