Skip to content

[UPGRADE] Replace moment.js with date-fns v3 #31

Description

@BAWES

Overview

Remove moment.js (~300KB bundle cost) and replace all usages with date-fns v3 which is already in package.json at v2. This issue upgrades date-fns to v3 and removes moment entirely.

Can be done independently

This issue has no dependency on the Angular upgrade path and can be worked on in parallel.

Scope

1. Upgrade date-fns to v3

npm install date-fns@3
npm uninstall moment

2. Find all moment usages

grep -r "moment" src/ --include="*.ts" --include="*.html" -l

3. Replace common patterns

moment.js date-fns v3 equivalent
moment().format('DD/MM/YYYY') format(new Date(), 'dd/MM/yyyy')
moment(date).fromNow() formatDistanceToNow(date, { addSuffix: true })
moment(date).diff(other, 'days') differenceInDays(date, other)
moment(date).add(7, 'days') addDays(date, 7)
moment(date).isBefore(other) isBefore(date, other)
moment(date).startOf('month') startOfMonth(date)
moment(date).isValid() isValid(date)
moment(str, 'YYYY-MM-DD') parse(str, 'yyyy-MM-dd', new Date())

4. Note on date-fns v2 → v3 breaking changes

  • date-fns v3 is ESM-first — all imports must be named imports from date-fns
  • date-fns/esm sub-path no longer exists in v3
  • Some locale imports changed: import { enUS } from 'date-fns/locale'

Acceptance Criteria

  • moment removed from package.json
  • No import moment or import * as moment anywhere in src/
  • ng build completes successfully
  • All date formatting displays correctly throughout the app
  • Date comparisons/calculations work correctly (verify on: candidate view, leave requests, work log)
  • Bundle size reduced (verify with npx source-map-explorer dist/)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions