Extract shared date utility functions #13

Closed
opened 2026-02-08 06:44:19 -08:00 by kyle · 1 comment
Owner

Context: Several date manipulation patterns are repeated throughout the codebase:

  • .toISOString().split('T')[0] for date formatting (11+ occurrences)
  • setHours(0, 0, 0, 0) for day boundary normalization (multiple files)
  • Optional date field conversion logic duplicated for 6 fields in flights.service.ts

Files affected:

  • backend/src/drivers/schedule-export.service.ts (lines 39-43, 414-415, 438-439)
  • backend/src/copilot/copilot.service.ts (line 75)
  • backend/src/flights/flights.service.ts (lines 77-91)
  • 8+ other backend files

Suggested fix:

  • Create backend/src/common/utils/date.utils.ts with:
    • toDateString(date: Date): string
    • startOfDay(date: Date): Date
    • convertOptionalDates(obj, fields)

Effort: Trivial

**Context:** Several date manipulation patterns are repeated throughout the codebase: - `.toISOString().split('T')[0]` for date formatting (11+ occurrences) - `setHours(0, 0, 0, 0)` for day boundary normalization (multiple files) - Optional date field conversion logic duplicated for 6 fields in flights.service.ts **Files affected:** - `backend/src/drivers/schedule-export.service.ts` (lines 39-43, 414-415, 438-439) - `backend/src/copilot/copilot.service.ts` (line 75) - `backend/src/flights/flights.service.ts` (lines 77-91) - 8+ other backend files **Suggested fix:** - Create `backend/src/common/utils/date.utils.ts` with: - `toDateString(date: Date): string` - `startOfDay(date: Date): Date` - `convertOptionalDates(obj, fields)` **Effort:** Trivial
Author
Owner

Created with , , and . Updated all 10+ files.

Created with , , and . Updated all 10+ files.
kyle closed this issue 2026-02-08 07:09:58 -08:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kyle/vip-coordinator#13