I already have working (ugly) code for this, but I will ask anyway:
I have the time intervals [09:15, 10:00), [21:10, 21:45) during weekdays. Given time t
and a number of seconds s
, if t
is within the intervals, I have to calculate the date and time where t - s
would fall into.
- Example: t = 20130913 21:15, s = 600, t - s falls into 20130913 09:55.
- Example: t = 20130923 09:16, s = 120, t - s falls into 20130920 21:44.
Is there a way of doing this in C++ cleanly (boost::icl? boost::date_time?)
I have tried boost::icl, it can certainly hold the time ranges in an interval_set<Time>
and find which interval a certain Time
is in, but if t - s
time point does not fall into an interval range, I don't see how I can find the nearest interval before that time point, and how to detect if I have to go back a day or through the whole weekend.