1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-19 18:28:42 +00:00
Files
frontend/src/more-infos/more-info-sun.js
2016-07-17 23:18:48 -07:00

46 lines
888 B
JavaScript

import Polymer from '../polymer';
export default new Polymer({
is: 'more-info-sun',
properties: {
stateObj: {
type: Object,
},
risingDate: {
type: Object,
computed: 'computeRising(stateObj)',
},
settingDate: {
type: Object,
computed: 'computeSetting(stateObj)',
},
},
computeRising(stateObj) {
return new Date(stateObj.attributes.next_rising);
},
computeSetting(stateObj) {
return new Date(stateObj.attributes.next_setting);
},
computeOrder(risingDate, settingDate) {
return risingDate > settingDate ? ['set', 'ris'] : ['ris', 'set'];
},
itemCaption(type) {
return type === 'ris' ? 'Rising ' : 'Setting ';
},
itemDate(type) {
return type === 'ris' ? this.risingDate : this.settingDate;
},
itemValue(type) {
return window.hassUtil.formatTime(this.itemDate(type));
},
});