Fix timezones
This commit is contained in:
@@ -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