Weather API change backgrounds according to day and night

I have tried to figure this out on my own with no luck. I am using the FCC pass through. I have my backgrounds changing but they are all daytime pics looks funny when you look at it at night. Was thinking I could do an If to check if the icon was a day icon or night icon. Can’t for the life of me figure out how to check it.
Here is my Codepen: []

Why not base the background on the sunrise and sunset times?
Here is some pseudo code below:

if (currentTime > sunriseTime && currentTime < sunsetTime)

On a side note: Since you are displaying a wind metric, I think it would be great if you could use km when the Celsius temperature is showing and mph when Fahrenheit is showing.

I was thinking that after I asked. lol Actually I was think of making a sunset pic and setting a timer for it and thought duh I could just use Sunrise and Sunset. Would it be easier if I made sunrise and sunset a function? Thanks for the side note! Something else for me to work on lol

So what would be the logic making the decision to show a sunrise or sunset pic? I was thinking you just wanted to show a night or day version of the weather conditions. For example, if it Clouds and daytime, then it would show grey sky with clouds in it and if it was nighttime, you might darker grey/black background with hint of moon peaking through clouds to show it was night. For the scenario I am describing, you would only need one function called showBackground with the logic of the pseudo code I showed in the previous reply.

Was just brainstorming about different things I could do lol I got it I think! Need to plug in the right images. Thank you for your help! My images are acting strange on my phone. I think it is because of the loading animation. you can see the whole pic for a split second and it resizes and clips it off.

Well I thought I had it til I woke up and looked at it this morning and saw a night picture. Not sure what I did wrong.