import {describe, it, expect, beforeEach} from 'vitest'; import {Instant} from '@/'; import {TimeZone} from '@clarify/zone-data'; import importer from '@clarify/zone-data/importer'; describe('TimeZone', () => { let timeZone!: TimeZone; beforeEach(async () => { timeZone = await importer['Europe/Paris'](); }); describe('#getTimeZoneTransition', () => { it('with string as option', async () => { let now = Instant.from('2025-03-20T00:36:00Z').toZonedDateTimeISO(timeZone); let next = timeZone.getTimeZoneTransition(now.epochMilliseconds, 'next')!; let nextDate = Instant.fromEpochMilliseconds(next).toZonedDateTimeISO(timeZone); expect(nextDate.toString()).toEqual('2025-03-30T03:00:00.000+02:00[Europe/Paris]'); let previous = timeZone.getTimeZoneTransition(now.epochMilliseconds, 'previous')!; let previousDate = Instant.fromEpochMilliseconds(previous).toZonedDateTimeISO(timeZone); expect(previousDate.toString()).toEqual('2024-10-27T02:00:00.000+01:00[Europe/Paris]'); let nextAfter = timeZone.getTimeZoneTransition(nextDate.epochMilliseconds, 'next'); let previousAfter = timeZone.getTimeZoneTransition(previousDate.epochMilliseconds, 'previous'); let nextAfterDate = Instant.fromEpochMilliseconds(nextAfter!).toZonedDateTimeISO(timeZone); let previousAfterDate = Instant.fromEpochMilliseconds(previousAfter!).toZonedDateTimeISO(timeZone); expect(nextAfterDate.toString()).toEqual('2025-10-26T02:00:00.000+01:00[Europe/Paris]'); expect(previousAfterDate.toString()).toEqual('2024-03-31T03:00:00.000+02:00[Europe/Paris]'); }); }); });