import { describe, expect, it } from 'vitest' import { isSameLocalDay } from './dates' describe('isSameLocalDay', () => { it('matches two moments of the same local day', () => { const morning = new Date(2026, 9, 15, 8, 30) const night = new Date(2026, 9, 15, 23, 59) expect(isSameLocalDay(morning, night)).toBe(true) }) it('does not match moments across local midnight', () => { const justBefore = new Date(2026, 9, 15, 23, 59) const justAfter = new Date(2026, 9, 16, 0, 1) expect(isSameLocalDay(justBefore, justAfter)).toBe(false) }) it('compares in the local timezone, not in UTC', () => { // 23:30 local on Oct 15th is already Oct 16th in UTC for UTC-negative // timezones, so a naive UTC comparison would report different days. const localNight = new Date(2026, 9, 15, 23, 30) const nextLocalMidnight = new Date(2026, 9, 16, 0, 0) expect(isSameLocalDay(localNight, nextLocalMidnight)).toBe(false) }) })