Last active
June 23, 2017 09:08
-
-
Save Mark24Code/0955f28f1bc09e8153a91b2140893211 to your computer and use it in GitHub Desktop.
煮粥电饭煲计算预约时间
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""用于计算煮,粥预约时间""" | |
from datetime import datetime, timedelta, date | |
now_datetime = datetime.now() | |
cook_what = 'zhou' # 粥 | |
cooked_time = '6:00:00' # 次日时间 | |
cook_menu = { | |
'zhou': timedelta(hours=1, minutes=30) | |
} | |
today_date = date.today() | |
today_datetime = datetime(today_date.year, today_date.month, today_date.day) | |
tomorrow_datetime = today_datetime + timedelta(hours=24) | |
cooked_hours, cooked_minutes, cooked_seconds = list(map(int, cooked_time.split(':'))) | |
cooked_datetime = tomorrow_datetime + timedelta(hours=cooked_hours, minutes=cooked_minutes, seconds=cooked_seconds) | |
left_timedelta = cooked_datetime - now_datetime - cook_menu[cook_what] | |
print(left_timedelta) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment