mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Correct relative time logic (#1231)
This commit is contained in:
parent
348943f221
commit
2f6bb9af0c
@ -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]) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user