datetime_utility.js.coffee 795 字节
Newer Older
A
Alfredo Sumaran 已提交
1 2 3 4
((w) ->

  w.gl ?= {}
  w.gl.utils ?= {}
5
  w.gl.utils.days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
A
Alfredo Sumaran 已提交
6 7 8 9

  w.gl.utils.formatDate = (datetime) ->
    dateFormat(datetime, 'mmm d, yyyy h:MMtt Z')

10 11 12
  w.gl.utils.getDayName = (date) ->
    this.days[date.getDay()]

13
  w.gl.utils.localTimeAgo = ($timeagoEls, setTimeago = true) ->
A
Alfredo Sumaran 已提交
14 15 16 17 18
    $timeagoEls.each( ->
          $el = $(@)
          $el.attr('title', gl.utils.formatDate($el.attr('datetime')))
    )

19 20 21 22 23 24 25 26
    if setTimeago
      $timeagoEls.timeago()
      $timeagoEls.tooltip('destroy')

      # Recreate with custom template
      $timeagoEls.tooltip(
        template: '<div class="tooltip local-timeago" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
      )
27

A
Alfredo Sumaran 已提交
28
) window