Fix python to js timestamp conversions in logbook traces (#12677)

- The websocket version needs the time converted from
  where python stores the decimal
This commit is contained in:
J. Nick Koston 2022-05-18 14:36:08 -05:00 committed by GitHub
parent c41e100c1c
commit 6c48ace41e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -194,7 +194,7 @@ export class HaTracePathDetails extends LitElement {
// it's the last entry. Find all logbook entries after start.
const startTime = new Date(startTrace[0].timestamp);
const idx = this.logbookEntries.findIndex(
(entry) => new Date(entry.when) >= startTime
(entry) => new Date(entry.when * 1000) >= startTime
);
if (idx === -1) {
entries = [];
@ -210,7 +210,7 @@ export class HaTracePathDetails extends LitElement {
entries = [];
for (const entry of this.logbookEntries || []) {
const entryDate = new Date(entry.when);
const entryDate = new Date(entry.when * 1000);
if (entryDate >= startTime) {
if (entryDate < endTime) {
entries.push(entry);

View File

@ -116,7 +116,7 @@ class LogbookRenderer {
maybeRenderItem() {
const logbookEntry = this.curItem;
this.curIndex++;
const entryDate = new Date(logbookEntry.when);
const entryDate = new Date(logbookEntry.when * 1000);
if (this.pendingItems.length === 0) {
this.pendingItems.push([entryDate, logbookEntry]);
@ -248,7 +248,7 @@ class ActionRenderer {
// Render all logbook items that are in front of this item.
while (
this.logbookRenderer.hasNext &&
new Date(this.logbookRenderer.curItem.when) < timestamp
new Date(this.logbookRenderer.curItem.when * 1000) < timestamp
) {
this.logbookRenderer.maybeRenderItem();
}