tracking-exposed / trex

youtube & tiktok analysis + youchoose recommendation custmizer. backend, extensions, and tooling
https://docs.tracking.exposed
GNU Affero General Public License v3.0
52 stars 15 forks source link

Replace `moment` with `date-fns` #351

Open ascariandrea opened 2 years ago

ascariandrea commented 2 years ago

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:

vecna commented 2 years ago

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?

ascariandrea commented 2 years ago

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.