Hourly schedule for a weeks or months [QA]
Hi @mmamaev , first of all thanks for such a great package! Trying different settings for build, I think, very basic schedule. Need to display hourly schedule for a next few weeks for example and have a two different layouts, one for day hours and one for week days, so and can't mix it together. p.s. asked here, because it can be a useful scenario.
Thanks
Hi, Did you mean something like: on Mondays, Wednesdays, Fridays we work from 8 am to 2 pm; on Tuesdays and Thursdays we work instead from 2 pm to 8 pm, and on Saturdays and Sundays we've got holidays? This is it:
>>> day_a_hours = tb.Marker(each='D',
... at=[{'hours':8}, {'hours':14}])
>>> day_b_hours = tb.Marker(each='D',
... at=[{'hours':14}, {'hours':20}])
>>> day_a = tb.Organizer(marker=day_a_hours, structure=[0, 1, 0])
>>> day_b = tb.Organizer(marker=day_b_hours, structure=[0, 1, 0])
>>> weekly = tb.Organizer('D', structure=[day_a, day_b, day_a, day_b, day_a, 0, 0])
>>> clnd = tb.Timeboard(base_unit_freq='H',
... start='04 May 2020', end='17 May 2020',
... layout=weekly,
... default_selector=lambda label: label>0)
Awesome! Thank you for answering this question as it solved my dilemma also. I needed a schedule to match the following stipulations:
Work hours: 08:00 ~ 14:00 Work days: Monday through Saturday
or
Work hours: 12:00 ~ 18:00 Work days: Monday, Wednesday, Friday
Below is the code I need to get mine functional for more examples:
start_time = {"hour": shift[0].hour, "minute": shift[0].minute}
end_time = {"hour": shift[1].hour, "minute": shift[1].minute}
day_parts = tb.Marker(each="D", at=[start_time, end_time])
day = tb.Organizer(marker=day_parts, structure=[0, 1, 0])
day_structure = [day if working else 0 for working in working_days]
weekly = tb.Organizer(marker="D", structure=day_structure)
timeboard = tb.Timeboard(
base_unit_freq="T",
start=departure_time - self.DELTA,
end=departure_time,
layout=weekly,
)