diff --git a/app/utils/charts.ts b/app/utils/charts.ts index b3dc1e6f1..d22750aa9 100644 --- a/app/utils/charts.ts +++ b/app/utils/charts.ts @@ -32,12 +32,6 @@ export function buildWeeklyEvolutionFromDaily( }) } -export function addDays(date: Date, days: number): Date { - const d = new Date(date) - d.setUTCDate(d.getUTCDate() + days) - return d -} - // Statistics & Interpretation utilities export function clamp(value: number, minValue: number, maxValue: number): number { diff --git a/test/unit/app/utils/charts.spec.ts b/test/unit/app/utils/charts.spec.ts index b57028abd..050799c8f 100644 --- a/test/unit/app/utils/charts.spec.ts +++ b/test/unit/app/utils/charts.spec.ts @@ -3,7 +3,6 @@ import { sum, chunkIntoWeeks, buildWeeklyEvolutionFromDaily, - addDays, clamp, quantile, winsorize, @@ -325,59 +324,6 @@ describe('buildWeeklyEvolutionFromDaily', () => { }) }) -describe('addDays', () => { - it('returns a new Date instance (does not mutate original)', () => { - const original = new Date('2028-01-01T00:00:00Z') - const result = addDays(original, 5) - - expect(result).not.toBe(original) - expect(original.toISOString()).toBe('2028-01-01T00:00:00.000Z') - }) - - it('adds positive days correctly', () => { - const date = new Date('2028-01-01T00:00:00Z') - const result = addDays(date, 10) - - expect(result.toISOString()).toBe('2028-01-11T00:00:00.000Z') - }) - - it('subtracts days when negative value is provided', () => { - const date = new Date('2028-01-10T00:00:00Z') - const result = addDays(date, -5) - - expect(result.toISOString()).toBe('2028-01-05T00:00:00.000Z') - }) - - it('handles month overflow correctly', () => { - const date = new Date('2028-01-28T00:00:00Z') - const result = addDays(date, 5) - - expect(result.toISOString()).toBe('2028-02-02T00:00:00.000Z') - }) - - it('handles year overflow correctly', () => { - const date = new Date('2027-12-29T00:00:00Z') - const result = addDays(date, 5) - - expect(result.toISOString()).toBe('2028-01-03T00:00:00.000Z') - }) - - it('handles leap year correctly', () => { - const date = new Date('2028-02-27T00:00:00Z') // 2028 is leap year - const result = addDays(date, 2) - - expect(result.toISOString()).toBe('2028-02-29T00:00:00.000Z') - }) - - it('keeps UTC behavior consistent (no timezone drift)', () => { - const date = new Date('2028-03-01T00:00:00Z') - const result = addDays(date, 1) - - expect(result.getUTCHours()).toBe(0) - expect(result.toISOString()).toBe('2028-03-02T00:00:00.000Z') - }) -}) - describe('clamp', () => { it('returns the value when it is within bounds', () => { expect(clamp(5, 0, 10)).toBe(5)