Fix timezones
Build Backend / build (push) Successful in 1m54s
Build Frontend / build (push) Successful in 3m43s

This commit is contained in:
2026-05-30 16:55:01 +02:00
parent 91184cfc96
commit 8852cf202e
6 changed files with 31 additions and 28 deletions
@@ -62,8 +62,8 @@ describe('SleepTimetable', () => {
fireEvent(window, new Event('resize'));
// Check for 3-day interval tabs
// In reversed order (25, 24, 23...), the first group is Fri - Wed
expect(screen.getByRole('button', { name: /Fri \d+ - Wed \d+/i })).toBeInTheDocument();
// In reversed order (25, 24, 23...), the first group is Wed - Fri
expect(screen.getByRole('button', { name: /Wed \d+ - Fri \d+/i })).toBeInTheDocument();
});
it('renders in small mode (single-day tabs and 1-column grid)', () => {
+16
View File
@@ -11,6 +11,7 @@ import {
timeToMinutes,
adjustForTimezone,
getLocalOffsetFromReference,
formatDateTime,
} from '../../src/utils/time';
describe('formatMinutesAfter', () => {
@@ -125,6 +126,21 @@ describe('adjustForTimezone', () => {
});
});
describe('formatDateTime', () => {
it('treats string without Z as UTC', () => {
const dateStr = '2024-01-15T10:00:00';
const dateWithZ = '2024-01-15T10:00:00Z';
expect(formatDateTime(dateStr)).toBe(formatDateTime(dateWithZ));
});
it('formats a Date object correctly', () => {
const date = new Date('2024-01-15T10:00:00Z');
// The output depends on the local timezone, so we check for part of it
const result = formatDateTime(date);
expect(result).toMatch(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}/);
});
});
describe('getLocalOffsetFromReference', () => {
it('returns local offset from reference in minutes', () => {
const utcMins = 600; // 10:00 UTC