No idea what it is doing... very sad

This commit is contained in:
2026-06-07 19:59:31 +02:00
parent cfc3156906
commit 969b8e033f
4 changed files with 90 additions and 4 deletions
+26
View File
@@ -13,6 +13,7 @@ import {
getLocalOffsetFromReference,
formatDateTime,
toUTCFromLocalInput,
parseBackendDateTime,
} from '../../src/utils/time';
describe('formatMinutesAfter', () => {
@@ -167,4 +168,29 @@ describe('toUTCFromLocalInput', () => {
expect(toUTCFromLocalInput('2026-06-0')).toBe('');
});
});
describe('parseBackendDateTime', () => {
it('should parse a UTC string without Z as UTC', () => {
const time = '2026-06-04 13:58:00';
const date = parseBackendDateTime(time);
expect(date.toISOString()).toBe('2026-06-04T13:58:00.000Z');
});
it('should parse a UTC string with Z as UTC', () => {
const time = '2026-06-04T13:58:00Z';
const date = parseBackendDateTime(time);
expect(date.toISOString()).toBe('2026-06-04T13:58:00.000Z');
});
it('should parse a string with an offset correctly', () => {
const time = '2026-06-04T13:58:00+02:00';
const date = parseBackendDateTime(time);
expect(date.toISOString()).toBe('2026-06-04T11:58:00.000Z');
});
it('should handle ISO format with T', () => {
const time = '2026-06-04T13:58:00';
const date = parseBackendDateTime(time);
expect(date.toISOString()).toBe('2026-06-04T13:58:00.000Z');
});
});