2017-01-16 18:30:54 +01:00
|
|
|
import { Blaze } from 'meteor/blaze';
|
|
|
|
|
import { Session } from 'meteor/session';
|
|
|
|
|
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('jsDateFromNow', function(context, format, options) {
|
2016-05-07 08:58:46 +02:00
|
|
|
if (!context) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Session.get('timeAgoVariable');
|
|
|
|
|
|
|
|
|
|
var dateAsMoment = moment(new Date(context));
|
|
|
|
|
return dateAsMoment.fromNow();
|
|
|
|
|
});
|