Skip to content

Instantly share code, notes, and snippets.

@Davis-3450
Created September 29, 2025 02:51
Show Gist options
  • Save Davis-3450/d2127e3a3ddc5d56224a708dcb4c80c1 to your computer and use it in GitHub Desktop.
Save Davis-3450/d2127e3a3ddc5d56224a708dcb4c80c1 to your computer and use it in GitHub Desktop.
class WorkHour(int, Enum):
WORK_START = 8
LUNCH_START = 12
LUNCH_END = 13
WORK_END = 17
def is_working_hour(self) -> bool:
t = date.time()
morning_ok = time(WorkHour.WORK_START.value, 0) <= t < time(WorkHour.LUNCH_START.value, 0)
afternoon_ok = time(WorkHour.LUNCH_END.value, 0) <= t < time(WorkHour.WORK_END.value, 0)
return morning_ok or afternoon_ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment