diff --git a/Brocfile.js b/Brocfile.js index 7005e48..644f168 100644 --- a/Brocfile.js +++ b/Brocfile.js @@ -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(); diff --git a/app/helpers/null-time.js b/app/helpers/null-time.js index 2baa675..67fbe1c 100644 --- a/app/helpers/null-time.js +++ b/app/helpers/null-time.js @@ -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); }); diff --git a/app/templates/strains/show.hbs b/app/templates/strains/show.hbs index 35085a3..8c50468 100644 --- a/app/templates/strains/show.hbs +++ b/app/templates/strains/show.hbs @@ -23,15 +23,15 @@
Created
-
{{model.createdAt}}
+
{{null-time model.createdAt 'LL'}}
Updated
-
{{model.updatedAt}}
+
{{null-time model.updatedAt 'LL'}}
Deleted
-
{{model.deletedAt}}
+
{{null-time model.deletedAt 'LL'}}
diff --git a/app/utils/date-helpers.js b/app/utils/date-helpers.js new file mode 100644 index 0000000..c493e38 --- /dev/null +++ b/app/utils/date-helpers.js @@ -0,0 +1,7 @@ +function formatDate(date, format) { + return window.moment(date).format(format); +} + +export { + formatDate +}; diff --git a/bower.json b/bower.json index 20cd854..cb5bcfc 100644 --- a/bower.json +++ b/bower.json @@ -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" } } diff --git a/tests/unit/utils/date-helpers-test.js b/tests/unit/utils/date-helpers-test.js new file mode 100644 index 0000000..2be4a6f --- /dev/null +++ b/tests/unit/utils/date-helpers-test.js @@ -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); +});