feat: show bought items in a collapsible section for the current day only
Some checks failed
CI / Verify (push) Has been cancelled
Some checks failed
CI / Verify (push) Has been cancelled
Bought items now move down to a 'Comprados hoy' collapsible section (expanded by default) below the pending ones, and are only visible on the local day they were bought. Items bought on previous days stay completed in the database but are hidden from the list.
This commit is contained in:
28
apps/web/src/lib/dates.test.ts
Normal file
28
apps/web/src/lib/dates.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user