Calculating sunrise and sunset times
Winter can be a dismal time in the UK. At least we’re now a few days past the winter solstice, so the mornings and evenings are starting to get brighter. Well, just about! So to pass the time until it’s fit to be out in my Caterham again I searched for an algorithm to calculate sunrise and sunset times. There’s lots of new-fangled APIs and other modern code available. Joyously, I also found a BASIC program published in August 1994 by Sky & Telescope magazine.
It runs on the RC2014 with a couple of minor alterations. The easy change is to convert the comment statements from using a single quotation mark to the more standard REM. The less graceful change converts the PRINT USING <format> statements to PRINT. This means that hours and minutes aren’t displayed with a leading zero. (There’s obviously a string conversion or two I could write to remedy this, but I have more ambitious plans).
It takes a couple of seconds to run. Here’s today’s sunrise and sunset times for Derby (52.9225N, 1.4746W) and for somewhere near the North Pole, just in case Santa is reading.

I think there are some nice graphics I could add to this. At some point the code will probably make its way over onto one of my Sharp MZ machines. Oh, and the code could really use some refactoring. Initialising variables and constants using a GOSUB? Yuk.
The code, with the minimal edits required for it to work with 4.7b BASIC, is in my RC2014 github repository.