forked from external-repos/pa11y-dashboard
Add a view helper for date formatting
This commit is contained in:
20
view/helper/date.js
Normal file
20
view/helper/date.js
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var moment = require('moment');
|
||||
|
||||
module.exports = helper;
|
||||
|
||||
function helper (register) {
|
||||
|
||||
// Format a date with Moment
|
||||
register('date-format', function (context, block) {
|
||||
var format = block.hash.format || 'YYYY-MM-DD HH:mm:ss';
|
||||
return moment(context).format(format);
|
||||
});
|
||||
|
||||
// Get a relative date
|
||||
register('date-relative', function (context) {
|
||||
return moment(context).fromNow();
|
||||
});
|
||||
|
||||
};
|
Reference in New Issue
Block a user