I have shift
which is a datetime interval (a pair of datetime
s). My weeks have a labeled partition (every week is the same: divided into parts, and each part has a label). I want to split up shift
into labeled parts (i.e. into several subintervals), according to the partition of the week.
Example. Suppose shift
is the interval 2019-10-21 18:30
- 2019-10-22 08:00
, and the partition of the week is as follows: Monday to Friday 07:00 - 19:00 has label A
, and the rest of the week has label B
. In this case the splitting of shift
should be the following list of labeled subintervals:
2019-10-21 18:30
-2019-10-21 19:00
with labelA
,2019-10-21 19:00
-2019-10-22 07:00
with labelB
, and2019-10-22 07:00
-2019-10-22 08:00
with labelA
.
How do I do this in general?
Input: a datetime
interval (pair), and a labeled partition of the week (how to best represent this?)
Output: a list of labeled datetime
intervals (pairs).
from Split up datetime interval according to labeled partition of a week
No comments:
Post a Comment