Skip to content

Instantly share code, notes, and snippets.

View jceaser's full-sized avatar

Thomas Cherry jceaser

View GitHub Profile
@jacopofar
jacopofar / sunrise_sunshine.py
Created May 17, 2019 17:47
Sunrise and sunshine calculation in pure Python 3.7
"""Calculate the sunrise, sunset and noon time for a given coordinate.
Based on the code at: https://michelanders.blogspot.com/2010/12/calulating-sunrise-and-sunset-in-python.html
"""
from math import cos, sin, acos, asin, tan
from math import degrees as deg, radians as rad
from datetime import datetime, time, timezone, timedelta
class Sun:
"""
@Tafkas
Tafkas / computeSunrise.js
Last active August 3, 2023 20:04
A simple sunrise-sunset algorithm taken from http://williams.best.vwh.net/sunrise_sunset_algorithm.htm in JavaScript
function computeSunrise(day, sunrise) {
/*Sunrise/Sunset Algorithm taken from
http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
inputs:
day = day of the year
sunrise = true for sunrise, false for sunset
output:
time of sunrise/sunset in hours */