Files
mozo-backend/app/assets/javascripts/shared-ember-helpers/time.js.coffee
T

11 lines
500 B
CoffeeScript

Ember.Handlebars.helper 'time', (time, params..., options = {})->
return '' unless time
time = new Date(time) if typeof(time) is "string"
iso = time.toISOString()
if options.hash.format
format_string = "data-time-format=\"#{options.hash.format}\""
else
format_string = ''
tag = if options.bare then iso else $("<span data-time=\"#{iso}\" #{format_string}></span>").text(moment(iso).format(options.hash.format || 'dd D MMM hh:mm')).get(0).outerHTML
new Handlebars.SafeString tag