Fix incorrect date selection ranges for history and logbook (#8045)

This commit is contained in:
Philip Allgaier 2021-01-04 10:04:14 +01:00 committed by GitHub
parent 293b56cfa6
commit e6d38f4539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 34 deletions

View File

@ -119,27 +119,21 @@ class HaPanelHistory extends LitElement {
todayEnd.setDate(todayEnd.getDate() + 1); todayEnd.setDate(todayEnd.getDate() + 1);
todayEnd.setMilliseconds(todayEnd.getMilliseconds() - 1); todayEnd.setMilliseconds(todayEnd.getMilliseconds() - 1);
const todayCopy = new Date(today); const yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
const yesterday = new Date(todayCopy.setDate(today.getDate() - 1)); const yesterdayEnd = new Date(today);
const yesterdayEnd = new Date(yesterday);
yesterdayEnd.setDate(yesterdayEnd.getDate() + 1);
yesterdayEnd.setMilliseconds(yesterdayEnd.getMilliseconds() - 1); yesterdayEnd.setMilliseconds(yesterdayEnd.getMilliseconds() - 1);
const thisWeekStart = new Date( const thisWeekStart = new Date(today);
todayCopy.setDate(today.getDate() - today.getDay()) thisWeekStart.setDate(today.getDate() - today.getDay());
); const thisWeekEnd = new Date(thisWeekStart);
const thisWeekEnd = new Date( thisWeekEnd.setDate(thisWeekStart.getDate() + 7);
todayCopy.setDate(thisWeekStart.getDate() + 7)
);
thisWeekEnd.setMilliseconds(thisWeekEnd.getMilliseconds() - 1); thisWeekEnd.setMilliseconds(thisWeekEnd.getMilliseconds() - 1);
const lastWeekStart = new Date( const lastWeekStart = new Date(today);
todayCopy.setDate(today.getDate() - today.getDay() - 7) lastWeekStart.setDate(today.getDate() - today.getDay() - 7);
); const lastWeekEnd = new Date(lastWeekStart);
const lastWeekEnd = new Date( lastWeekEnd.setDate(lastWeekStart.getDate() + 7);
todayCopy.setDate(lastWeekStart.getDate() + 7)
);
lastWeekEnd.setMilliseconds(lastWeekEnd.getMilliseconds() - 1); lastWeekEnd.setMilliseconds(lastWeekEnd.getMilliseconds() - 1);
this._ranges = { this._ranges = {

View File

@ -147,27 +147,21 @@ export class HaPanelLogbook extends LitElement {
todayEnd.setDate(todayEnd.getDate() + 1); todayEnd.setDate(todayEnd.getDate() + 1);
todayEnd.setMilliseconds(todayEnd.getMilliseconds() - 1); todayEnd.setMilliseconds(todayEnd.getMilliseconds() - 1);
const todayCopy = new Date(today); const yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
const yesterday = new Date(todayCopy.setDate(today.getDate() - 1)); const yesterdayEnd = new Date(today);
const yesterdayEnd = new Date(yesterday);
yesterdayEnd.setDate(yesterdayEnd.getDate() + 1);
yesterdayEnd.setMilliseconds(yesterdayEnd.getMilliseconds() - 1); yesterdayEnd.setMilliseconds(yesterdayEnd.getMilliseconds() - 1);
const thisWeekStart = new Date( const thisWeekStart = new Date(today);
todayCopy.setDate(today.getDate() - today.getDay()) thisWeekStart.setDate(today.getDate() - today.getDay());
); const thisWeekEnd = new Date(thisWeekStart);
const thisWeekEnd = new Date( thisWeekEnd.setDate(thisWeekStart.getDate() + 7);
todayCopy.setDate(thisWeekStart.getDate() + 7)
);
thisWeekEnd.setMilliseconds(thisWeekEnd.getMilliseconds() - 1); thisWeekEnd.setMilliseconds(thisWeekEnd.getMilliseconds() - 1);
const lastWeekStart = new Date( const lastWeekStart = new Date(today);
todayCopy.setDate(today.getDate() - today.getDay() - 7) lastWeekStart.setDate(today.getDate() - today.getDay() - 7);
); const lastWeekEnd = new Date(lastWeekStart);
const lastWeekEnd = new Date( lastWeekEnd.setDate(lastWeekStart.getDate() + 7);
todayCopy.setDate(lastWeekStart.getDate() + 7)
);
lastWeekEnd.setMilliseconds(lastWeekEnd.getMilliseconds() - 1); lastWeekEnd.setMilliseconds(lastWeekEnd.getMilliseconds() - 1);
this._ranges = { this._ranges = {