feat(stats): implement SleepTimetable with enhanced date formatting and fixed tests
Build Frontend / build (push) Failing after 10m34s

This commit is contained in:
2026-06-11 17:18:21 +02:00
parent bb58389675
commit da76baa2ae
4 changed files with 23 additions and 17 deletions
@@ -9,15 +9,16 @@ interface TimetableProps {
day_end: string;
}
function getDayName(dateStr: string) {
export function getDayName(dateStr: string) {
return new Date(dateStr + 'T00:00:00').toLocaleDateString('en-US', { weekday: 'short' });
}
function formatDayLabel(dateStr: string) {
export function formatDayLabel(dateStr: string) {
const date = new Date(dateStr + 'T00:00:00');
const weekday = date.toLocaleDateString('en-US', { weekday: 'short' });
const day = date.getDate();
return `${weekday} ${day}`;
const month = date.getMonth() + 1;
return `${weekday} ${day}/${month}`;
}
function formatTimeLabel(mins: number) {
@@ -176,7 +177,7 @@ const Timetable = ({ from_date, to_date, day_start, day_end }: TimetableProps) =
<div className="h-2" /> {/* Empty corner cell */}
{visibleDays.map((day) => (
<div key={day} className="text-center text-[10px] font-medium text-gray-500 uppercase flex items-center justify-center h-2">
{getDayName(day)}
{formatDayLabel(day)}
</div>
))}
</div>
@@ -0,0 +1,9 @@
import { describe, it, expect } from 'vitest';
import { formatDayLabel } from '../SleepTimetable';
describe('formatDayLabel', () => {
it('formats date as "Weekday D/M"', () => {
expect(formatDayLabel('2025-06-09')).toBe('Mon 9/6');
expect(formatDayLabel('2025-06-10')).toBe('Tue 10/6');
});
});