Backbone-moment
About Backbone-moment
This plugin modifies Backbone.Model adding a convenient getter/setter for date attributes using moment.js
var myModel = ; var fooDate = ; myModel; myModel; // returns "1997-01-01T06:00:00+00:00" moment; // is true // [http://momentjs.com/docs/#/query/is-same/](http://momentjs.com/docs/#/query/is-same/)myModel; // is true
Additionally you can use the shorthand moment for getting and setting
var fooDate = ; myModel; myModel; // is true
You can clear a moment by setting undefined
, null
, or ````
myModel; myModel; // returns undefined
Backbone.__moment
is a reference to moment.
If you have a modified or specially loaded moment, you will need to shim in a copy.
;Backbone__moment = ;
By default backbone-moment
stores dates as UTC strings
Override Backbone.Model.formatMoment
if you need to change this behavior
var MyModel = BackboneModel;
Project Details
Library Downloads
You can download the latest builds directly from the dist folder above.
Available Packages
Via npm
$ npm install backbone-moment
Via bower
$ bower install backbone-moment
Currently Backbone-moment is available via npm and bower. If you would like add it to another channel, please open an issue.
Changelog
For change logs and release notes, see the changelog file.
Compatibility and Requirements
Backbone-moment supports IE8+ and modern browsers.
Github Issues
Report issues with Backbone-moment, and submit pull requests to fix problems or to create summarized and documented feature requests (preferably with the feature implemented in the pull request).
===
This library is © 2015 Paul Falgout. Distributed under MIT license.