在工作日周一至周五,周六,周日中的时间间隔

问题描述

  1. 工作日中从00到08、08到16、16到21、21到24的拆分时间
  2. 将星期六的时间分为两种,从8点到12点,其余时间为一个时间
  3. 全日制单一类型
from datetime import date,time
import calendar

Now = date.today()
start_time = input("Enter the start time: ".format("%H:%M"))
end_time = input("Enter the end time: ".format("%H:%M"))

def timeline(start_time,end_time):
    current_time = Now.strftime("%H:%M")
>*to display all time in sunday as full-over time*
    for calendar.SUNDAY in current_time:
        if start_time == time(0,0) and end_time == time(23,59): return "Full-over time in Sundays"
>*to split and display time interval in saturdays*     
    for calendar.SATURDAY in current_time:
        if start_time >= time(8,00) and end_time <= time(11,59): return "Half-Over time in saturdays"
        else: return "Full-over time in Saturdays"
>*to split and display time interval in weekdays for example in Monday*
    for calendar.MONDAY in current_time:
        if start_time >= time(8,00) and end_time <= time(15,59): return "normal weekday hour"
        elif start_time >= time(16,00) and end_time <= time(20,59): return "Half-Over weekday"
        else: return "Full-Over weekday"

    return current_time

print(timeline)

代码未执行,我将非常感谢您提供的有关解决代码或进行任何更改的帮助

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)