At most one date library
Why it matters
Two date libraries mean two timezone-handling strategies, two parsing APIs, and two bundle payloads. date-fns treats dates as immutable UTC-first while dayjs mirrors Moment's mutable-looking API — code that mixes both produces DST-transition bugs that only fire twice a year. Formatting output drifts between components (one says "Jan 5" the other says "1/5"), and locale handling requires loading the right locale pack into the right library or date strings silently fall back to English.
Severity rationale
Medium because DST and timezone bugs are real correctness issues, but they're bounded to date-display and scheduling features.
Remediation
Wrap your chosen library in src/utils/dates.ts and import only that wrapper from the rest of the codebase.
// src/utils/dates.ts
import { format, parseISO } from 'date-fns'
export const formatDate = (d: Date) => format(d, 'yyyy-MM-dd')
export const parseDate = (s: string) => parseISO(s)
Rewrite every dayjs call site, then npm uninstall dayjs. Add an ESLint rule forbidding direct imports of the removed library anywhere outside the wrapper module to prevent regression.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Multi-Session Drift Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-slop-code-drift·automated