Skip to content

Instantly share code, notes, and snippets.

@Mark24Code
Last active June 23, 2017 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mark24Code/0955f28f1bc09e8153a91b2140893211 to your computer and use it in GitHub Desktop.
Save Mark24Code/0955f28f1bc09e8153a91b2140893211 to your computer and use it in GitHub Desktop.
煮粥电饭煲计算预约时间
# -*- 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