Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hourly schedule for a weeks or months [QA] #10

Open
yesaulov opened this issue Apr 1, 2020 · 2 comments
Open

Hourly schedule for a weeks or months [QA] #10

yesaulov opened this issue Apr 1, 2020 · 2 comments
Labels

Comments

@yesaulov
Copy link

yesaulov commented Apr 1, 2020

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

@mmamaev
Copy link
Owner

mmamaev commented May 1, 2020

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)

@crsiebler
Copy link

crsiebler commented Mar 6, 2021

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,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants