Improved pretty date (just now).
This commit is contained in:
parent
b4e2548150
commit
cd69cba3f0
2 changed files with 11 additions and 2 deletions
|
@ -26,6 +26,9 @@ class App.PrettyDate
|
|||
diff = diff.toString().replace('-', '')
|
||||
diff = parseFloat(diff)
|
||||
|
||||
if diff < 60
|
||||
return App.i18n.translateInline('just now')
|
||||
|
||||
if direction is 'past' && !escalation && diff > ( 60 * 60 * 24 * 14 )
|
||||
return App.i18n.translateDate(time)
|
||||
|
||||
|
|
|
@ -5,7 +5,10 @@ test( "check pretty date", function() {
|
|||
|
||||
// past
|
||||
var result = App.PrettyDate.humanTime( current );
|
||||
equal( result, '0 minutes ago', 'right now')
|
||||
equal( result, 'just now', 'just now')
|
||||
|
||||
result = App.PrettyDate.humanTime( current - 15000 );
|
||||
equal( result, 'just now', 'just now')
|
||||
|
||||
result = App.PrettyDate.humanTime( current - 60000 );
|
||||
equal( result, '1 minute ago', '1 min ago')
|
||||
|
@ -60,7 +63,10 @@ test( "check pretty date", function() {
|
|||
// future
|
||||
current = new Date()
|
||||
result = App.PrettyDate.humanTime( current );
|
||||
equal( result, '0 minutes ago', 'right now')
|
||||
equal( result, 'just now', 'just now')
|
||||
|
||||
result = App.PrettyDate.humanTime( current.getTime() + 55000 );
|
||||
equal( result, 'just now', 'just now')
|
||||
|
||||
result = App.PrettyDate.humanTime( current.getTime() + 65000 );
|
||||
equal( result, 'in 1 minute', 'in 1 min')
|
||||
|
|
Loading…
Reference in a new issue