From 589ebecffe1c14c0224f8444ce7f324b2d5218ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E6=B6=A6=E5=BA=AD?= Date: Tue, 31 Dec 2019 20:03:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E8=BF=98=E6=9C=AA?= =?UTF-8?q?=E5=88=B0=E6=9C=80=E6=97=A9=E9=A2=84=E5=94=AE=E6=97=B6=E9=97=B4?= =?UTF-8?q?=EF=BC=8C=E5=B0=B1=E5=BC=80=E5=A7=8B=E6=9F=A5=E8=AF=A2=E8=BD=A6?= =?UTF-8?q?=E7=A5=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init/select_ticket_info.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/init/select_ticket_info.py b/init/select_ticket_info.py index 1dc01425..060ce705 100755 --- a/init/select_ticket_info.py +++ b/init/select_ticket_info.py @@ -133,14 +133,19 @@ def main(self): now = datetime.datetime.now() if TickerConfig.ORDER_MODEL is 1: - print(f"预售还未开始,阻塞中,预售时间为{TickerConfig.OPEN_TIME}, 当前时间为: {now.strftime('%H:%M:%S')}") sleep_time_s = 0.1 sleep_time_t = 0.3 # 测试了一下有微妙级的误差,应该不影响,测试结果:2019-01-02 22:30:00.004555,预售还是会受到前一次刷新的时间影响,暂时没想到好的解决方案 - while now.strftime("%H:%M:%S") < TickerConfig.OPEN_TIME: + earliest_departure_date_str = min(TickerConfig.STATION_DATES) + earliest_pre_sale_date = datetime.datetime.strptime(earliest_departure_date_str, "%Y-%m-%d") - \ + datetime.timedelta(days=29) + earliest_pre_sale_date_str = earliest_pre_sale_date.strftime("%Y-%m-%d") + earliest_pre_sale_datetime_str = earliest_pre_sale_date_str + " " + TickerConfig.OPEN_TIME + print(f"预售还未开始,阻塞中,最早预售时间为{earliest_pre_sale_datetime_str}, 当前时间为: {now.strftime('%Y-%m-%d %H:%M:%S')}") + while now.strftime("%Y-%m-%d %H:%M:%S") < earliest_pre_sale_datetime_str: now = datetime.datetime.now() time.sleep(0.0001) - print(f"预售开始,开启时间为: {now.strftime('%H:%M:%S')}") + print(f"预售开始,开启时间为: {earliest_pre_sale_datetime_str}") else: sleep_time_s = TickerConfig.MIN_TIME sleep_time_t = TickerConfig.MAX_TIME