Add moment.js support

This commit is contained in:
Matthew Dillon 2015-03-19 09:17:09 -08:00
parent f8d75d821f
commit c886a51b7d
6 changed files with 27 additions and 6 deletions

View file

@ -19,5 +19,7 @@ app.import('bower_components/gridforms/gridforms/gridforms.js');
app.import('bower_components/flakes/js/base.js');
// nprogress
app.import('bower_components/nprogress/nprogress.js');
// moment
app.import('bower_components/moment/moment.js');
module.exports = app.toTree();

View file

@ -1,8 +1,9 @@
import Ember from 'ember';
import { formatDate } from '../utils/date-helpers';
export default Ember.Handlebars.makeBoundHelper(function(value, options) {
export default Ember.Handlebars.makeBoundHelper(function(value, format) {
if (value == null) {
return 'N/A';
}
return value;
return formatDate(value, format);
});

View file

@ -23,15 +23,15 @@
<div class="grid-4">
<dl class="span-1">
<dt>Created</dt>
<dd>{{model.createdAt}}</dd>
<dd>{{null-time model.createdAt 'LL'}}</dd>
</dl>
<dl class="span-1">
<dt>Updated</dt>
<dd>{{model.updatedAt}}</dd>
<dd>{{null-time model.updatedAt 'LL'}}</dd>
</dl>
<dl class="span-1">
<dt>Deleted</dt>
<dd>{{model.deletedAt}}</dd>
<dd>{{null-time model.deletedAt 'LL'}}</dd>
</dl>
<dl class="span-1"></dl>
</div>

View file

@ -0,0 +1,7 @@
function formatDate(date, format) {
return window.moment(date).format(format);
}
export {
formatDate
};

View file

@ -14,6 +14,7 @@
"qunit": "~1.17.1",
"flakes": "~1.0.0",
"ember-simple-auth": "~0.7.2",
"nprogress": "~0.1.6"
"nprogress": "~0.1.6",
"moment": "~2.9.0"
}
}

View file

@ -0,0 +1,10 @@
import dateHelpers from '../../../utils/date-helpers';
import { module, test } from 'qunit';
module('dateHelpers');
// Replace this with your real tests.
test('it works', function(assert) {
var result = dateHelpers();
assert.ok(result);
});