Make frontend UTC aware
parent
e0ecb64a10
commit
54904a1630
|
@ -1,2 +1,2 @@
|
|||
""" DO NOT MODIFY. Auto-generated by build_frontend script """
|
||||
VERSION = "93774c7a1643c7e3f9cbbb1554b36683"
|
||||
VERSION = "37514744ac03f1d764a70b8e6a7e572f"
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -8,16 +8,17 @@
|
|||
</template>
|
||||
<script>
|
||||
(function() {
|
||||
var timeFormatOptions = {hour: 'numeric', minute: '2-digit'};
|
||||
var uiUtil = window.hass.uiUtil;
|
||||
|
||||
Polymer({
|
||||
time: "",
|
||||
|
||||
dateObjChanged: function(oldVal, newVal) {
|
||||
if (!newVal) {
|
||||
if (newVal) {
|
||||
this.time = uiUtil.formatTime(newVal);
|
||||
} else {
|
||||
this.time = "";
|
||||
}
|
||||
|
||||
this.time = newVal.toLocaleTimeString([], timeFormatOptions);
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<link rel="import" href="../resources/moment-js.html">
|
||||
|
||||
<polymer-element name="relative-ha-datetime" attributes="datetime">
|
||||
<polymer-element name="relative-ha-datetime" attributes="datetime datetimeObj">
|
||||
<template>
|
||||
{{ relativeTime }}
|
||||
</template>
|
||||
|
@ -34,8 +34,15 @@
|
|||
this.updateRelative();
|
||||
},
|
||||
|
||||
datetimeObjChanged: function(oldVal, newVal) {
|
||||
this.parsedDateTime = newVal;
|
||||
|
||||
this.updateRelative();
|
||||
},
|
||||
|
||||
updateRelative: function() {
|
||||
this.relativeTime = this.parsedDateTime ? moment(this.parsedDateTime).fromNow() : "";
|
||||
this.relativeTime = this.parsedDateTime ?
|
||||
moment(this.parsedDateTime).fromNow() : "";
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
</div>
|
||||
|
||||
<div class="time-ago">
|
||||
<core-tooltip label="{{stateObj.lastChanged}}" position="bottom">
|
||||
<relative-ha-datetime datetime="{{stateObj.lastChanged}}"></relative-ha-datetime>
|
||||
<core-tooltip label="{{stateObj.lastChangedAsDate | formatDateTime}}" position="bottom">
|
||||
<relative-ha-datetime datetimeObj="{{stateObj.lastChangedAsDate}}"></relative-ha-datetime>
|
||||
</core-tooltip>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 56f896efa573aaa9554812a3c41b78278bce2064
|
||||
Subproject commit 124b5df8ffb08bd7db22912865dba80845815e5d
|
|
@ -7,18 +7,6 @@
|
|||
'light', 'group', 'sun', 'configurator', 'thermostat', 'script'
|
||||
];
|
||||
|
||||
// Register some polymer filters
|
||||
|
||||
PolymerExpressions.prototype.HATimeToDate = function(timeString) {
|
||||
if (!timeString) return;
|
||||
|
||||
return window.hass.util.parseDateTime(timeString);
|
||||
};
|
||||
|
||||
PolymerExpressions.prototype.HATimeStripDate = function(timeString) {
|
||||
return (timeString || "").split(' ')[0];
|
||||
};
|
||||
|
||||
// Add some frontend specific helpers to the models
|
||||
Object.defineProperties(window.hass.stateModel.prototype, {
|
||||
// how to render the card for this state
|
||||
|
@ -81,3 +69,5 @@
|
|||
window.hass.uiUtil = {};
|
||||
})();
|
||||
</script>
|
||||
|
||||
<link rel="import" href="./moment-js.html">
|
||||
|
|
|
@ -3,3 +3,22 @@
|
|||
-->
|
||||
|
||||
<script src="../bower_components/moment/moment.js"></script>
|
||||
|
||||
<script>
|
||||
window.hass.uiUtil.formatTime = function(dateObj) {
|
||||
return moment(dateObj).format('LT');
|
||||
};
|
||||
|
||||
window.hass.uiUtil.formatDateTime = function(dateObj) {
|
||||
return moment(dateObj).format('lll');
|
||||
};
|
||||
|
||||
window.hass.uiUtil.formatDate = function(dateObj) {
|
||||
return moment(dateObj).format('ll');
|
||||
};
|
||||
|
||||
PolymerExpressions.prototype.formatTime = window.hass.uiUtil.formatTime;
|
||||
PolymerExpressions.prototype.formatDateTime = window.hass.uiUtil.formatDateTime;
|
||||
PolymerExpressions.prototype.formatDate = window.hass.uiUtil.formatDate;
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue