mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-16 05:46:35 +00:00
Use finishes_at in timer remaining calculation (#22169)
* Use finishes_at in timer remaining calculation * lint * fix test
This commit is contained in:
parent
4c2044e70a
commit
ce9993fd36
@ -72,8 +72,8 @@ export const timerTimeRemaining = (
|
||||
|
||||
if (stateObj.state === "active") {
|
||||
const now = new Date().getTime();
|
||||
const madeActive = new Date(stateObj.last_changed).getTime();
|
||||
timeRemaining = Math.max(timeRemaining - (now - madeActive) / 1000, 0);
|
||||
const finishes = new Date(stateObj.attributes.finishes_at).getTime();
|
||||
timeRemaining = Math.max((finishes - now) / 1000, 0);
|
||||
}
|
||||
|
||||
return timeRemaining;
|
||||
|
@ -42,8 +42,8 @@ describe("timerTimeRemaining", () => {
|
||||
state: "active",
|
||||
attributes: {
|
||||
remaining: "0:01:05",
|
||||
finishes_at: "2018-01-17T16:16:17+00:00",
|
||||
},
|
||||
last_changed: "2018-01-17T16:15:12Z",
|
||||
} as any),
|
||||
47
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user