Add sunrise-sunset times on kneeboard

This commit is contained in:
Raffson 2023-11-18 23:46:38 +01:00
parent ade81f4548
commit 9907432a0a
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 19 additions and 0 deletions

View File

@ -32,6 +32,7 @@ from typing import Dict, Iterator, List, Optional, TYPE_CHECKING, Tuple
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
from dcs.mission import Mission from dcs.mission import Mission
from suntime import Sun
from tabulate import tabulate from tabulate import tabulate
from game.ato.flighttype import FlightType from game.ato.flighttype import FlightType
@ -431,6 +432,23 @@ class BriefingPage(KneeboardPage):
fl = self.flight fl = self.flight
start_pos = fl.waypoints[0].position.latlng()
sun = Sun(start_pos.lat, start_pos.lng)
date = fl.squadron.coalition.game.date
tz = fl.squadron.coalition.game.theater.timezone
# Get today's sunrise and sunset in UTC
sr_utc = sun.get_sunrise_time(date)
ss_utc = sun.get_sunset_time(date)
sr = sr_utc + tz.utcoffset(sun.get_sunrise_time(date))
ss = ss_utc + tz.utcoffset(sun.get_sunset_time(date))
writer.text(
f"Sunrise - Sunset: {sr.strftime('%H:%M')} - {ss.strftime('%H:%M')}"
f" ({sr_utc.strftime('%H:%M')} - {ss_utc.strftime('%H:%M')} UTC)"
)
if fl.bingo_fuel and fl.joker_fuel: if fl.bingo_fuel and fl.joker_fuel:
writer.table( writer.table(
[ [

View File

@ -52,6 +52,7 @@ shiboken6==6.4.3
six==1.16.0 six==1.16.0
sniffio==1.3.0 sniffio==1.3.0
starlette==0.27.0 starlette==0.27.0
suntime==1.2.5
tabulate==0.9.0 tabulate==0.9.0
text-unidecode==1.3 text-unidecode==1.3
toml==0.10.2 toml==0.10.2