mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-10 02:46:38 +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-list/mwc-list-item";
|
||||
import { mdiChevronRight } from "@mdi/js";
|
||||
import formatISO9075 from "date-fns/formatISO9075";
|
||||
import {
|
||||
css,
|
||||
CSSResultGroup,
|
||||
@ -69,12 +70,11 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
|
||||
public showDialog(params: DialogStatisticsAdjustSumParams): void {
|
||||
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();
|
||||
this._moment = `${now.getFullYear()}-${
|
||||
now.getMonth() + 1
|
||||
}-${now.getDate()} ${now.getHours()}:${
|
||||
now.getMinutes() - (now.getMinutes() % 5)
|
||||
}:00`;
|
||||
now.setMinutes(now.getMinutes() - (now.getMinutes() % 5), 0);
|
||||
this._moment = formatISO9075(now);
|
||||
this._fetchStats();
|
||||
}
|
||||
|
||||
@ -250,7 +250,10 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
this._stats5min = undefined;
|
||||
this._statsHour = undefined;
|
||||
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
|
||||
const hourStatStart = new Date(moment.getTime());
|
||||
|
Loading…
x
Reference in New Issue
Block a user