framework/ember/app/helpers/human-time.js

15 lines
393 B
JavaScript
Raw Normal View History

2014-12-20 14:26:46 +08:00
import Ember from 'ember';
2015-02-02 14:28:23 +08:00
import humanTime from '../utils/human-time';
2014-12-20 14:26:46 +08:00
export default Ember.Handlebars.makeBoundHelper(function(time) {
var m = moment(time);
2015-02-02 14:28:23 +08:00
var datetime = m.format();
var full = m.format('LLLL');
2014-12-20 14:26:46 +08:00
2015-02-02 14:28:23 +08:00
var ago = humanTime(m);
2014-12-20 14:26:46 +08:00
2015-02-02 14:28:23 +08:00
return new Ember.Handlebars.SafeString('<time pubdate datetime="'+datetime+'" title="'+full+'" data-humantime>'+ago+'</time>');
2014-12-20 14:26:46 +08:00
});