gitlab-org--gitlab-foss/app/assets/javascripts/lib/utils/datetime_utility.js.coffee

29 lines
795 B
CoffeeScript
Raw Normal View History

2016-04-07 13:00:19 -04:00
((w) ->
w.gl ?= {}
w.gl.utils ?= {}
w.gl.utils.days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
2016-04-07 13:00:19 -04:00
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) ->
2016-04-07 13:00:19 -04:00
$timeagoEls.each( ->
$el = $(@)
$el.attr('title', gl.utils.formatDate($el.attr('datetime')))
)
2016-05-24 19:40:27 -04:00
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>'
)
2016-04-07 13:00:19 -04:00
) window