Bases: object
A helper class to manage Studio working hours.
Working hours is a data class to store the weekly working hours pattern of the studio.
The data stored as a dictionary with the short day names are used as the key and the value is a list of two integers showing the working hours interval as the minutes after midnight. This is done in that way to ease the data transfer to TaskJuggler. The default value is defined in stalker.config.Config
wh = WorkingHours()
wh.working_hours = {
'mon': [[540, 720], [820, 1080]], # 9:00 - 12:00, 13:00 - 18:00
'tue': [[540, 720], [820, 1080]], # 9:00 - 12:00, 13:00 - 18:00
'wed': [[540, 720], [820, 1080]], # 9:00 - 12:00, 13:00 - 18:00
'thu': [[540, 720], [820, 1080]], # 9:00 - 12:00, 13:00 - 18:00
'fri': [[540, 720], [820, 1080]], # 9:00 - 12:00, 13:00 - 18:00
'sat': [], # saturday off
'sun': [], # sunday off
}
The default value is 9:00 - 18:00 from Monday to Friday and Saturday and Sunday are off.
The working hours can be updated by the user supplied dictionary. If the user supplied dictionary doesn’t have all the days then the default values will be used for those days.
It is possible to use day index and day short names as a key value to reach the data:
from stalker import config
defaults = config.Config()
wh = WorkingHours()
# this is same by doing wh.working_hours['sun']
assert wh['sun'] == defaults.working_hours['sun']
# you can reach the data using the weekday number as index
assert wh[0] == defaults.working_hours['mon']
# working hours of sunday if defaults are used or any other day defined
# by the stalker.config.Config.day_order
assert wh[0] == defaults.working_hours[defaults.day_order[0]]
Parameters: | working_hours – The dictionary that shows the working hours. The keys of the dictionary should be one of [‘mon’, ‘tue’, ‘wed’, ‘thu’, ‘fri’, ‘sat’, ‘sun’]. And the values should be a list of two integers like [[int, int], [int, int], ...] format, showing the minutes after midnight. For missing days the default value will be used. If skipped the default value is going to be used. |
---|
Methods
__init__([working_hours]) | |
is_working_hour(check_for_date) | checks if the given datetime is in working hours |
Attributes
to_tjp | returns TaskJuggler representation of this object |
weekly_working_days | returns the weekly working days by looking at the working hours |
weekly_working_hours | returns the total working hours in a week |
working_hours | the getter of _wh |
yearly_working_days | returns the total working days in a year |
checks if the given datetime is in working hours
Parameters: | check_for_date (datetime.datetime) – The time to check if it is a working hour |
---|