1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat: moon age instead of moon percentage

This commit is contained in:
2021-12-31 19:43:01 +01:00
parent 0e43cee95f
commit 04a2c83eb8

View File

@@ -105,7 +105,6 @@ in {
import astral
import astral.moon
import astral.sun
import math
moon_phases = {
0: "🌑",
@@ -121,12 +120,10 @@ in {
current_phase = astral.moon.phase()
closest_phase = min(moon_phases.keys(), key=lambda x: abs(current_phase - x))
moon_percentage = round(100 * math.sin(current_phase / 28 * math.pi), 1)
city = astral.LocationInfo("Berlin", "Germany", "${spacetime.time.timeZone}", ${toString spacetime.location.latitude}, ${toString spacetime.location.longitude})
sun = astral.sun.sun(city.observer, date=astral.today(), tzinfo=city.timezone)
print("🌅 {} 🌇 {} {} {}%".format(sun["sunrise"].strftime("%R"), sun["sunset"].strftime("%R"), moon_phases[closest_phase], moon_percentage))
print("🌅 {} 🌇 {} {} {}".format(sun["sunrise"].strftime("%R"), sun["sunset"].strftime("%R"), moon_phases[closest_phase], round(current_phase, 1)))
'';
}
{