Has anyone created a commonjs wrapper for Date.js? I'd like to use the Date.js library inside node and don't want to import it as a bare file and eval it if I can help it.
I wrote a date library similar to DateJS that doesn't modify the Date.prototype
. You may want to use that instead if you're worried about modifying the native Date object.
It handles parsing, manipulation, and formatting, as well as timeago and i18n.
npm install moment
Documentation at http://momentjs.com/docs
What do you mean by a 'commonjs wrapper'? This code worked fine for me:
require('./date');
console.log(Date.today().add(5).days());
Date is a global object, and when you do the require, date.js modifies the global object. It didn't seem to mess up the regular date stuff. I would personally want to refactor it, because modifying the global object seems a little scary to me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With