-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96e3cce
commit 5e1cd79
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import datetime | ||
|
||
from .calendar import Calendar | ||
|
||
|
||
class TimeAttribute: | ||
def __init__(self, time: datetime.time): | ||
self.time: datetime.time = time | ||
self.free: bool = False | ||
|
||
def is_free(self, calendar: Calendar) -> bool: | ||
if self.free: | ||
return True | ||
|
||
flow_time = calendar.flow_time | ||
hour = flow_time.hour | ||
minute = flow_time.minute | ||
if hour == self.time.hour and minute == self.time.minute: | ||
return True | ||
else: | ||
return False | ||
|
||
def reset(self): | ||
self.clear_free() | ||
|
||
def set_free(self): | ||
self.free = True | ||
|
||
def clear_free(self): | ||
self.free = False | ||
|
||
def calendar_changed(self, calendar: Calendar): | ||
if self.free: | ||
return | ||
if self.is_free(calendar): | ||
self.set_free() |