mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-21 18:46:10 +10:00
It will use $.timeago behind the scene and it does the opposite of what $.timeago does.
$.timefor("Thu Jun 05 2016 23:40:39 GMT+0300 (EEST)") will return "3 days remaining".
25 lines
507 B
CoffeeScript
25 lines
507 B
CoffeeScript
((w) ->
|
|
|
|
jQuery.timefor = (time, suffix, expiredLabel) ->
|
|
|
|
return '' unless time
|
|
|
|
suffix or= 'remaining'
|
|
expiredLabel or= 'expired'
|
|
|
|
jQuery.timeago.settings.allowFuture = yes
|
|
|
|
{ suffixFromNow } = jQuery.timeago.settings.strings
|
|
jQuery.timeago.settings.strings.suffixFromNow = suffix
|
|
|
|
timefor = $.timeago time
|
|
|
|
if timefor.indexOf('ago') > -1
|
|
timefor = expiredLabel
|
|
|
|
jQuery.timeago.settings.strings.suffixFromNow = suffixFromNow
|
|
|
|
return timefor
|
|
|
|
) window
|