@@ -25,7 +25,7 @@ Module.register("clock", {
2525 analogShowDate : "top" , // OBSOLETE, can be replaced with analogPlacement and showTime, options: false, 'top', or 'bottom'
2626 secondsColor : "#888888" , // DEPRECATED, use CSS instead. Class "clock-second-digital" for digital clock, "clock-second" for analog clock.
2727
28- showSunTimes : false ,
28+ showSunTimes : false , // options: boolean, { showSunNextEvent: boolean }
2929 showMoonTimes : false , // options: false, 'times' (rise/set), 'percent' (lit percent), 'phase' (current phase), or 'both' (percent & phase)
3030 lat : 47.630539 ,
3131 lon : - 122.344147
@@ -171,21 +171,28 @@ Module.register("clock", {
171171 if ( this . config . showSunTimes ) {
172172 const sunTimes = SunCalc . getTimes ( now , this . config . lat , this . config . lon ) ;
173173 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 ;
174+ let sunWrapperInnerHTML = "" ;
175+
176+ if ( this . config . showSunTimes . showSunNextEvent !== false ) {
177+ let nextEvent ;
178+ if ( now . isBefore ( sunTimes . sunrise ) ) {
179+ nextEvent = sunTimes . sunrise ;
180+ } else if ( now . isBefore ( sunTimes . sunset ) ) {
181+ nextEvent = sunTimes . sunset ;
182+ } else {
183+ const tomorrowSunTimes = SunCalc . getTimes ( now . clone ( ) . add ( 1 , "day" ) , this . config . lat , this . config . lon ) ;
184+ nextEvent = tomorrowSunTimes . sunrise ;
185+ }
186+ const untilNextEvent = moment . duration ( moment ( nextEvent ) . diff ( now ) ) ;
187+ const untilNextEventString = `${ untilNextEvent . hours ( ) } h ${ untilNextEvent . minutes ( ) } m` ;
188+
189+ sunWrapperInnerHTML = `<span class="${ isVisible ? "bright" : "" } "><i class="fas fa-sun" aria-hidden="true"></i> ${ untilNextEventString } </span>` ;
182190 }
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>` ;
191+
192+ sunWrapperInnerHTML += `<span><i class="fas fa-arrow-up" aria-hidden="true"></i> ${ formatTime ( this . config , sunTimes . sunrise ) } </span>`
193+ + `<span><i class="fas fa-arrow-down" aria-hidden="true"></i> ${ formatTime ( this . config , sunTimes . sunset ) } </span>` ;
194+
195+ sunWrapper . innerHTML = sunWrapperInnerHTML ;
189196 digitalWrapper . appendChild ( sunWrapper ) ;
190197 }
191198
0 commit comments