I have a site with a lot of these stand alone "snippets" so that you don't have to include/port an entire astronomy library just to get the Sun rise/set times, etc.
https://www.celestialprogramming.com/Most of them are written in JavaScript only, but specifically written to be easy to port to other languages.