Skip to content

Instantly share code, notes, and snippets.

View bayuah's full-sized avatar
🇮🇩
Indonesia

Bayu Aditya H. bayuah

🇮🇩
Indonesia
View GitHub Profile
@ruiokada
ruiokada / suntimes.js
Last active March 27, 2024 16:49
Calculate sunrise/sunset times from latitude/longitude coordinates using Javascript.
/**
* Calculates today's sunrise and sunset hours in local time (or in the given tz) for the given latitude, longitude.
* The tz parameter is mainly for the possible circumstance that your system timezone does not match the location
* you are currently at.
*
* Computations are based on the formulas found in:
* https://en.wikipedia.org/wiki/Julian_day#Converting_Julian_or_Gregorian_calendar_date_to_Julian_Day_Number
* https://en.wikipedia.org/wiki/Sunrise_equation#Complete_calculation_on_Earth
*
* @method suntimes