mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-12 20:06:33 +00:00
Fix Safari dates (#12222)
This commit is contained in:
parent
f78ce2c844
commit
65c4d02452
@ -1,6 +1,7 @@
|
|||||||
import "@material/mwc-button/mwc-button";
|
import "@material/mwc-button/mwc-button";
|
||||||
import "@material/mwc-list/mwc-list-item";
|
import "@material/mwc-list/mwc-list-item";
|
||||||
import { mdiChevronRight } from "@mdi/js";
|
import { mdiChevronRight } from "@mdi/js";
|
||||||
|
import formatISO9075 from "date-fns/formatISO9075";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
@ -69,12 +70,11 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
|||||||
|
|
||||||
public showDialog(params: DialogStatisticsAdjustSumParams): void {
|
public showDialog(params: DialogStatisticsAdjustSumParams): void {
|
||||||
this._params = params;
|
this._params = params;
|
||||||
|
// moment is in format YYYY-MM-DD HH:mm:ss because of selector
|
||||||
|
// Here we create a date with minutes set to %5
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
this._moment = `${now.getFullYear()}-${
|
now.setMinutes(now.getMinutes() - (now.getMinutes() % 5), 0);
|
||||||
now.getMonth() + 1
|
this._moment = formatISO9075(now);
|
||||||
}-${now.getDate()} ${now.getHours()}:${
|
|
||||||
now.getMinutes() - (now.getMinutes() % 5)
|
|
||||||
}:00`;
|
|
||||||
this._fetchStats();
|
this._fetchStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,10 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
|||||||
this._stats5min = undefined;
|
this._stats5min = undefined;
|
||||||
this._statsHour = undefined;
|
this._statsHour = undefined;
|
||||||
const statId = this._params!.statistic.statistic_id;
|
const statId = this._params!.statistic.statistic_id;
|
||||||
const moment = new Date(this._moment!);
|
|
||||||
|
// moment is in format YYYY-MM-DD HH:mm:ss because of selector
|
||||||
|
// Here we convert it to an ISO string.
|
||||||
|
const moment = new Date(this._moment!.replace(" ", "T"));
|
||||||
|
|
||||||
// Search 3 hours before and 3 hours after chosen time
|
// Search 3 hours before and 3 hours after chosen time
|
||||||
const hourStatStart = new Date(moment.getTime());
|
const hourStatStart = new Date(moment.getTime());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user