Skip to content

Commit

Permalink
Update internal date every second
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Kissling authored and pkissling committed Nov 5, 2023
1 parent e2c1777 commit 1495be0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"davidanson.vscode-markdownlint",
"redhat.vscode-yaml"
]
}
}
6 changes: 3 additions & 3 deletions src/clock-weather-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ export class ClockWeatherCard extends LitElement {
constructor () {
super()
this.currentDate = DateTime.now()
const msToNextMinute = (60 - this.currentDate.second) * 1000
setTimeout(() => setInterval(() => { this.currentDate = DateTime.now() }, 1000 * 60), msToNextMinute)
setTimeout(() => { this.currentDate = DateTime.now() }, msToNextMinute)
const msToNextSecond = (1000 - this.currentDate.millisecond)
setTimeout(() => setInterval(() => { this.currentDate = DateTime.now() }, 1000), msToNextSecond)
setTimeout(() => { this.currentDate = DateTime.now() }, msToNextSecond)
}

public static getStubConfig (_hass: HomeAssistant, entities: string[], entitiesFallback: string[]): Record<string, unknown> {
Expand Down

0 comments on commit 1495be0

Please sign in to comment.