11 lines
473 B
CoffeeScript
11 lines
473 B
CoffeeScript
App.TimeHelper = Ember.Helper.helper (params, options)->
|
|
return '' unless time = params[0]
|
|
time = new Date(time) if typeof(time) is "string"
|
|
iso = time.toISOString()
|
|
if options.format
|
|
format_string = "data-time-format=\"#{options.format}\""
|
|
else
|
|
format_string = ''
|
|
tag = if options.bare then iso else $("<span data-time=\"#{iso}\" #{format_string}></span>").text(moment(iso).format(options.format || 'dd D MMM hh:mm')).get(0).outerHTML
|
|
tag.htmlSafe()
|