Dunlop.register_setup 'time-display', (target) ->
  # Display load time
  target.find('[data-time]').each (i) ->
    time = moment($(@).data('time'))
    moment_format = $(@).data('format') || 'LLL' # LL means only date: TODO: Make default LLL since there is a data-date option -> done!
    switch moment_format
      when 'relative'
        $(@).text time.fromNow()
        interval 10000, =>
          $(@).text time.fromNow()
      else
        $(@).text time.format(moment_format)

  # Display date
  target.find('[data-date]').each (i) ->
    time = moment($(@).data('date'))
    moment_format = $(@).data('format') || 'LL' # LL means only date
    switch moment_format
      when 'relative'
        $(@).text time.fromNow()
        interval 10000, =>
          $(@).text time.fromNow()
      else
        $(@).text time.format(moment_format)

