@@ -26,6 +26,7 @@ Module.register("clock", {
2626 secondsColor : "#888888" , // DEPRECATED, use CSS instead. Class "clock-second-digital" for digital clock, "clock-second" for analog clock.
2727
2828 showSunTimes : false ,
29+ showSunNextEvent : true ,
2930 showMoonTimes : false , // options: false, 'times' (rise/set), 'percent' (lit percent), 'phase' (current phase), or 'both' (percent & phase)
3031 lat : 47.630539 ,
3132 lon : - 122.344147
@@ -171,21 +172,28 @@ Module.register("clock", {
171172 if ( this . config . showSunTimes ) {
172173 const sunTimes = SunCalc . getTimes ( now , this . config . lat , this . config . lon ) ;
173174 const isVisible = now . isBetween ( sunTimes . sunrise , sunTimes . sunset ) ;
174- let nextEvent ;
175- if ( now . isBefore ( sunTimes . sunrise ) ) {
176- nextEvent = sunTimes . sunrise ;
177- } else if ( now . isBefore ( sunTimes . sunset ) ) {
178- nextEvent = sunTimes . sunset ;
179- } else {
180- const tomorrowSunTimes = SunCalc . getTimes ( now . clone ( ) . add ( 1 , "day" ) , this . config . lat , this . config . lon ) ;
181- nextEvent = tomorrowSunTimes . sunrise ;
175+ let sunWrapperInnerHTML = "" ;
176+
177+ if ( this . config . showSunNextEvent ) {
178+ let nextEvent ;
179+ if ( now . isBefore ( sunTimes . sunrise ) ) {
180+ nextEvent = sunTimes . sunrise ;
181+ } else if ( now . isBefore ( sunTimes . sunset ) ) {
182+ nextEvent = sunTimes . sunset ;
183+ } else {
184+ const tomorrowSunTimes = SunCalc . getTimes ( now . clone ( ) . add ( 1 , "day" ) , this . config . lat , this . config . lon ) ;
185+ nextEvent = tomorrowSunTimes . sunrise ;
186+ }
187+ const untilNextEvent = moment . duration ( moment ( nextEvent ) . diff ( now ) ) ;
188+ const untilNextEventString = `${ untilNextEvent . hours ( ) } h ${ untilNextEvent . minutes ( ) } m` ;
189+
190+ sunWrapperInnerHTML = `<span class="${ isVisible ? "bright" : "" } "><i class="fas fa-sun" aria-hidden="true"></i> ${ untilNextEventString } </span>` ;
182191 }
183- const untilNextEvent = moment . duration ( moment ( nextEvent ) . diff ( now ) ) ;
184- const untilNextEventString = `${ untilNextEvent . hours ( ) } h ${ untilNextEvent . minutes ( ) } m` ;
185- sunWrapper . innerHTML
186- = `<span class="${ isVisible ? "bright" : "" } "><i class="fas fa-sun" aria-hidden="true"></i> ${ untilNextEventString } </span>`
187- + `<span><i class="fas fa-arrow-up" aria-hidden="true"></i> ${ formatTime ( this . config , sunTimes . sunrise ) } </span>`
188- + `<span><i class="fas fa-arrow-down" aria-hidden="true"></i> ${ formatTime ( this . config , sunTimes . sunset ) } </span>` ;
192+
193+ sunWrapperInnerHTML += `<span><i class="fas fa-arrow-up" aria-hidden="true"></i> ${ formatTime ( this . config , sunTimes . sunrise ) } </span>`
194+ + `<span><i class="fas fa-arrow-down" aria-hidden="true"></i> ${ formatTime ( this . config , sunTimes . sunset ) } </span>` ;
195+
196+ sunWrapper . innerHTML = sunWrapperInnerHTML ;
189197 digitalWrapper . appendChild ( sunWrapper ) ;
190198 }
191199
0 commit comments