Skip to content

Commit

Permalink
#72 过期包裹一周一次
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorReid committed Nov 14, 2023
1 parent 3c46a09 commit 3146947
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/basic/os_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ def get_dt(utc_offset: int = None) -> str:
return current_time.strftime("%Y%m%d")


def get_sunday_dt(dt: str) -> str:
"""
根据一个日期,获取对应星期天的日期
:param dt: 日期 yyyyMMdd 格式
:return: 星期天日期 yyyyMMdd 格式
"""
date = datetime.datetime.strptime(dt, "%Y%m%d")
weekday = date.weekday() # 0表示星期一,6表示星期天
days_to_sunday = 6 - weekday
sunday_date = date + datetime.timedelta(days=days_to_sunday)
return sunday_date.strftime("%Y%m%d")


def clear_outdated_debug_files(days: int = 3):
"""
清理过期的调试临时文件
Expand Down
17 changes: 15 additions & 2 deletions src/sr/app/routine/buy_parcel.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Optional

from basic import Point
from basic import Point, os_utils
from basic.i18_utils import gt
from sr.app import Application, AppRunRecord, app_const
from sr.app import Application, AppRunRecord, app_const, app_record_current_dt_str
from sr.config import game_config
from sr.const import game_config_const, map_const
from sr.context import Context
Expand All @@ -22,6 +22,19 @@ class BuyParcelRecord(AppRunRecord):
def __init__(self):
super().__init__(app_const.BUY_XIANZHOU_PARCEL.id)

@property
def run_status_under_now(self):
"""
基于当前时间显示的运行状态
:return:
"""
current_dt = app_record_current_dt_str()
sunday_dt = os_utils.get_sunday_dt(self.dt)
if current_dt > sunday_dt:
return AppRunRecord.STATUS_WAIT
else:
return self.run_status


buy_parcel_record: Optional[BuyParcelRecord] = None

Expand Down

0 comments on commit 3146947

Please sign in to comment.