Welcome to mirror list, hosted at ThFree Co, Russian Federation.

datetime_utility.js.coffee « utils « lib « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2371e913844ca27bc7282d99431bcc0d24e5c273 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
((w) ->

  w.gl ?= {}
  w.gl.utils ?= {}
  w.gl.utils.days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']

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

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

  w.gl.utils.localTimeAgo = ($timeagoEls, setTimeago = true) ->
    $timeagoEls.each( ->
          $el = $(@)
          $el.attr('title', gl.utils.formatDate($el.attr('datetime')))
    )

    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>'
      )

) window