2017-01-16 18:30:54 +01:00
|
|
|
import { Blaze } from 'meteor/blaze';
|
|
|
|
|
import { moment } from 'meteor/momentjs:moment';
|
|
|
|
|
|
2016-05-07 08:58:46 +02:00
|
|
|
/**
|
|
|
|
|
* A global Blaze UI helper function to format JavaScript Dates using the Moment library
|
|
|
|
|
*/
|
2017-01-16 18:30:54 +01:00
|
|
|
Blaze.registerHelper('formatJSDate', function(context, format, options) {
|
2016-05-07 08:58:46 +02:00
|
|
|
if (!context) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dateAsMoment = moment(new Date(context));
|
|
|
|
|
var strFormat = 'MMM D, YYYY';
|
|
|
|
|
if (options) {
|
|
|
|
|
strFormat = format;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dateAsMoment.format(strFormat);
|
|
|
|
|
});
|