LoginSignup
1
1

pythonを使ってff14の世界エオルゼアで虹が出る時刻を予測できます

Last updated at Posted at 2024-04-23

eorzeaenvというff14ユーザーなら嬉しいライブラリを発見しました
こちらのウェブサイトに、虹が出る時刻を予測できるプログラムがあったので、
時刻を「年、月、日、時、分」を入れて表示できるプログラムにしてみました

とりあえず光の戦士のみなさまはこれを入れましょう

pip install eorzeaenv
rainbow.py
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
from EorzeaEnv import EorzeaPlaceName, EorzeaRainbow, EorzeaTime, EorzeaWeather

rainbow_times: list[str] = []
jst = ZoneInfo("Asia/Tokyo")
place = EorzeaPlaceName("東ラノシア") # ()内を変えると別の場所の時刻が出ます
the_rainbow = EorzeaRainbow(place_name=place)

for t in EorzeaTime.weather_period(step='inf'):
    the_rainbow.append(t, EorzeaWeather.forecast(place, t, raw=True))
    if the_rainbow.is_appear:
        # UNIX タイムスタンプを JST に変換してフォーマット
        jst_time = datetime.fromtimestamp(t.get_unix_time(), jst)
        formatted_time = f"{jst_time.year}{jst_time.month}{jst_time.day}{jst_time.hour}{jst_time.minute}"
        rainbow_times.append(formatted_time)
    if len(rainbow_times) == 5: #ここの値を変えると虹が出る日付をたくさん表示したりできます
        break

for time in rainbow_times:
    print(time)  

出力結果です

2024年4月23日 19時16分
2024年4月25日 3時56分
2024年4月25日 5時6分
2024年4月25日 7時26分
2024年4月25日 9時46分
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1