mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
standardize more-info-weather and add hourly/daily (#2766)
This commit is contained in:
parent
e7b664a2ff
commit
f127bbc64d
@ -105,8 +105,11 @@ class MoreInfoWeather extends LocalizeMixin(PolymerElement) {
|
|||||||
<template is="dom-if" if="[[_showValue(item.condition)]]">
|
<template is="dom-if" if="[[_showValue(item.condition)]]">
|
||||||
<iron-icon icon="[[getWeatherIcon(item.condition)]]"></iron-icon>
|
<iron-icon icon="[[getWeatherIcon(item.condition)]]"></iron-icon>
|
||||||
</template>
|
</template>
|
||||||
<div class="main">[[computeDateTime(item.datetime)]]</div>
|
<template is="dom-if" if="[[!_showValue(item.templow)]]">
|
||||||
|
<div class="main">[[computeDateTime(item.datetime)]]</div>
|
||||||
|
</template>
|
||||||
<template is="dom-if" if="[[_showValue(item.templow)]]">
|
<template is="dom-if" if="[[_showValue(item.templow)]]">
|
||||||
|
<div class="main">[[computeDate(item.datetime)]]</div>
|
||||||
<div class="templow">
|
<div class="templow">
|
||||||
[[item.templow]] [[getUnit('temperature')]]
|
[[item.templow]] [[getUnit('temperature')]]
|
||||||
</div>
|
</div>
|
||||||
@ -170,21 +173,8 @@ class MoreInfoWeather extends LocalizeMixin(PolymerElement) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
computeDateTime(data) {
|
computeDate(data) {
|
||||||
const date = new Date(data);
|
const date = new Date(data);
|
||||||
const provider = this.stateObj.attributes.attribution;
|
|
||||||
if (
|
|
||||||
provider === "Powered by Dark Sky" ||
|
|
||||||
provider === "Data provided by OpenWeatherMap"
|
|
||||||
) {
|
|
||||||
if (new Date().getDay() === date.getDay()) {
|
|
||||||
return date.toLocaleTimeString(this.hass.language, { hour: "numeric" });
|
|
||||||
}
|
|
||||||
return date.toLocaleDateString(this.hass.language, {
|
|
||||||
weekday: "long",
|
|
||||||
hour: "numeric",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return date.toLocaleDateString(this.hass.language, {
|
return date.toLocaleDateString(this.hass.language, {
|
||||||
weekday: "long",
|
weekday: "long",
|
||||||
month: "short",
|
month: "short",
|
||||||
@ -192,6 +182,14 @@ class MoreInfoWeather extends LocalizeMixin(PolymerElement) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
computeDateTime(data) {
|
||||||
|
const date = new Date(data);
|
||||||
|
return date.toLocaleDateString(this.hass.language, {
|
||||||
|
weekday: "long",
|
||||||
|
hour: "numeric",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getUnit(measure) {
|
getUnit(measure) {
|
||||||
const lengthUnit = this.hass.config.unit_system.length || "";
|
const lengthUnit = this.hass.config.unit_system.length || "";
|
||||||
switch (measure) {
|
switch (measure) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user