I am creating a schedule application and I need a way to classify a range of days for each block. Days are marked as integers:
MON, TUE, WEN, THU, FRI, SAT, SUN 0, 1, 2, 3, 4, 5, 6
So, let's say I planned a block that starts on Tuesday and ends on Friday. Determining its range is easy:
range(block.start_day, block.end_day +1) would give me (1, 4) .
But this will not work if the block starts on Saturday and ends on Wednesday.
As a result, I need (5, 6, 0, 1, 2) .
I am a bit stuck in this part. I think I could use the modulo operator, but I'm not sure.
** EDIT ** Sorry, I updated the correct desired result.
Using Python 2.7.6
python
Saša kalaba
source share