Fix negative seconds by displaying 0 instead (#1445) (#1625)

* Fix from-now.pipe.ts so it never displays negative seconds

* Apply the fix only when returning seconds. Remove redundant Math.floor operation
pull/1631/head
zacharystenger 2019-02-12 00:16:15 -08:00 committed by Chocobozzz
parent 7519127b5c
commit ec24796ea8
1 changed files with 1 additions and 1 deletions

View File

@ -35,6 +35,6 @@ export class FromNowPipe implements PipeTransform {
interval = Math.floor(seconds / 60)
if (interval >= 1) return this.i18n('{{interval}} min ago', { interval })
return this.i18n('{{interval}} sec ago', { interval: Math.floor(seconds) })
return this.i18n('{{interval}} sec ago', { interval: Math.max(0, seconds) })
}
}