trex icon indicating copy to clipboard operation
trex copied to clipboard

Replace `moment` with `date-fns`

Open ascariandrea opened this issue 3 years ago • 2 comments

moment is actually quite heavy and can be easily replaced with date-fns (already in use in the project). This will consolidate our "date" api and methods. We can also think about creating proper shared utils and helpers usable by every package.

Tasks:

  • [x] replace moment occurrences with date-fns in extension
  • [ ] replace moment occurrences with date-fns in yttrex
  • [x] replace moment occurrences with date-fns in guardoni
  • [x] replace moment occurrences with date-fns in ycai
  • [ ] replace moment occurrences with date-fns in tktrex
  • [ ] remove moment from every workspace package.json

ascariandrea avatar Feb 01 '22 13:02 ascariandrea

moment is often used for:

  1. moment.duration (measure the distance between two times and return an humanized version)
  2. moment.add/moment.subtract
  3. moment.isBefore/moment.isAfter

are there functionalities supported by date-fns?

vecna avatar Feb 01 '22 13:02 vecna

yep @vecna, date-fns provides proper methods to achieve everything you can get with moment.

I opened this PR #355 that shows how can be used for formatting and operate (add/sub) on dates.

ascariandrea avatar Feb 02 '22 12:02 ascariandrea