3 ms·
If the concern is around library size, sure, I'm on board with not needing MomentJS in many contexts. But my bigger worry is around people doing time based math
by mabbo 7y ago
If the concern is around library size, sure, I'm on board with not needing MomentJS in many contexts. But my bigger worry is around people doing time based math/logic themselves. Don't do that. Use a library.
Timezones (there are way more than you think); daylight savings time (it's far more complex than you think); leap seconds; Logic around "is X plus 30 minutes after Y?" (you haven't considered every edge case).
Libraries in these contexts will save you from outages, bugs, etc. They've considered these edge cases. I primarily work in a Java world these days, and the java.time additions in Java 8 are (imho) more important than the Lambda additions. (And yes, there was Joda-time before, but the Joda author has explicitly said you should use java.time.)
So sure, if you're just getting the date in a specific format you can forgo MomentJS. But as soon as you start to want to do more things, maybe weigh in whether it's worth the size or not. That library is large because it contains a lot of important knowledge.