mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 13:54:20 +03:00
parent
c31eefac1c
commit
5e1919d054
@ -202,19 +202,20 @@ class WeatherTile extends React.Component<WeatherTileProps, WeatherTileState> {
|
|||||||
const d = data['weather'][0];
|
const d = data['weather'][0];
|
||||||
const bg = this.colorFromCondition(data);
|
const bg = this.colorFromCondition(data);
|
||||||
|
|
||||||
const sunset = moment(moment().format('YYYY-MM-DD') + ' ' + d.astronomy[0].sunset, 'YYYY-MM-DD hh:mm A');
|
const sunset = moment(moment().hours(1).format('YYYY-MM-DD') + ' ' + d.astronomy[0].sunset, 'YYYY-MM-DD hh:mm A');
|
||||||
const sunsetDiff = sunset.diff(moment(), 'hours');
|
let sunsetDiff = sunset.diff(moment(), 'hours');
|
||||||
|
|
||||||
const sunrise = moment(moment().format('YYYY-MM-DD') + ' ' + d.astronomy[0].sunrise, 'YYYY-MM-DD hh:mm A');
|
const sunrise = moment(moment().hours(1).format('YYYY-MM-DD') + ' ' + d.astronomy[0].sunrise, 'YYYY-MM-DD hh:mm A');
|
||||||
let sunriseDiff = sunrise.diff(moment(), 'hours');
|
let sunriseDiff = sunrise.diff(moment(), 'hours');
|
||||||
|
|
||||||
if (sunriseDiff > 24) {
|
if (sunsetDiff < 0) {
|
||||||
sunriseDiff = sunriseDiff - 24;
|
sunsetDiff = sunsetDiff + 24;
|
||||||
} else if (sunriseDiff < 0) {
|
}
|
||||||
|
if (sunriseDiff < 0) {
|
||||||
sunriseDiff = sunriseDiff + 24;
|
sunriseDiff = sunriseDiff + 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextSolarEvent = sunsetDiff > 0
|
const nextSolarEvent = sunsetDiff < sunriseDiff
|
||||||
? `Sun sets in ${sunsetDiff}h`
|
? `Sun sets in ${sunsetDiff}h`
|
||||||
: `Sun rises in ${sunriseDiff}h`;
|
: `Sun rises in ${sunriseDiff}h`;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user