Fitness and everything else

Adding Sunrise And Sunset Times To My Weather pages

I have been wanting to include sunrise and sunset data into my weather page history for a while now. I thought that would be nice to have at a glance.

My first thought was to use an algorithm to generate it from the date and my location. That would have made the most sense. Unfortunately, Zola doesn’t have the math implemented. I’ll keep an eye out to see if it’s added, but I can’t imagine there’s much of a use case for these functions besides for me.

My next best thought was to use an API to get the information. I found several free ones that worked well enough. The only problem with that approach is that Zola would call the APIs every time it built. That added a minute or two to the build time. Sure, it’s not that much, especially considering I did all the HTML manually at one point. I’m impatient. The other gotcha with using an API is that it can have limits, or they can go away with little notice. That’s not even considering that servers go down for all sorts of reasons.

Finally, on my search, I found that NOAA has a page at NOAA Improved Sunrise/Sunset Calculation. That webpage lets you generate the times for one day. It didn’t solve my problem exactly, but I discovered they have a downloadable spreadsheet that can generate a year’s worth of data. It’s not as set it and forget it as having the formula in the template would be, but it’s a reasonable compromise. Although it takes an extra step to save that spreadsheet as a CSV file, I’d only have to do that once a year, and I’ve already got 2024 done. It’s a couple of extra steps, but it’s not a daily multistep process, with plenty of chances for errors between typos and copying and pasting the wrong information.