Fix timezones
This commit is contained in:
@@ -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)', () => {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user