Skip to content

Commit

Permalink
after_sunet
Browse files Browse the repository at this point in the history
  • Loading branch information
liguoqinjim committed May 22, 2024
1 parent 3edf5b6 commit 6a8fbb0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/v5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
schedule:
# 每天更新4次,大更新在7:30-8:30以及19:30-20:30,小更新(仅中东部城市)出现在13:30和1:30。
- cron: '50 0,5,12,17 * * *' #github action的时区不是北京时间,所有都减去8
- cron: '50 0,5,12,17 * * *' # github action的时区不是北京时间,所有都减去8,即北京时间是8点、13点、18点、23点

permissions: write-all # {{secrets.GITHUB_TOKEN}}的权限

Expand Down
22 changes: 18 additions & 4 deletions v5/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,31 @@ def is_before_sunrise():
sunrise_time = datetime(now.year, now.month, now.day, 5, 0, 0) # 设置日出时间为早上5点
return now.hour < sunrise_time.hour

def is_after_sunset():
"""
判断现在是否为日落之后,也就是晚上
"""
now = datetime.now()
sunset_time = datetime(now.year, now.month, now.day, 20, 0, 0) # 设置日落时间为晚上7点
return now.hour > sunset_time.hour

def get_info():
before_sunrise = is_before_sunrise()
after_sunset = is_after_sunset()

if before_sunrise: # 今日日出和今日日落
get_info_from_api(event="rise_1")
time.sleep(2)
get_info_from_api(event="set_1")
else: # 今日日落和明日日出
get_info_from_api(event="set_1")
time.sleep(2)
get_info_from_api(event="rise_2")
else:
if not after_sunset: # 今日日落和明日日出
get_info_from_api(event="set_1")
time.sleep(2)
get_info_from_api(event="rise_2")
else: # 日落之后,明日日出和明日日落
get_info_from_api(event="rise_2")
time.sleep(2)
get_info_from_api(event="set_2")

def run():
"""
Expand Down

0 comments on commit 6a8fbb0

Please sign in to comment.