Correct relative time logic (#1231)

This commit is contained in:
c727 2018-05-30 13:18:14 +02:00 committed by GitHub
parent 348943f221
commit 2f6bb9af0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,8 +10,9 @@ const tests = [
];
export default function relativeTime(dateObj) {
let delta = Math.abs((new Date() - dateObj) / 1000);
let delta = (new Date() - dateObj) / 1000;
const format = delta >= 0 ? '%s ago' : 'in %s';
delta = Math.abs(delta);
for (let i = 0; i < tests.length; i += 2) {
if (delta < tests[i]) {