Back to SpyD Blog

section-logoSpyD Blog


Goodbye Moment.js?

Published: Sun Apr 04 2021


Out with the old https://momentjs.com/

In with the new - https://moment.github.io/luxon/

I now think I should move on from Moment.js

It has been a great tool to workaround the date issues that javascript used to have, and now even though I find it comforting like a favorite t-shirt, I see the reasons to move on.

Recently, I realized that while using moment with typescript it fails the very fundamental purpose of using typescript.

When you pass a string date to a function that is typed with a moment.Moment type, it will hapily accept the string date into the function where it will fail when you run a moment method on it. Thats not how typescript is supposed to work.

Anyhow I am moving on to Luxon, and my way to do that will be to abstract all moment date functions to an abstraction class and connect it to moment, once it is totally abstracted, I will reconnect it to luxon.

back to top