
2011/1/5 John Rocha
Thank you for the tips on the interval library.
Hi John, thank you for looking at Boost.Icl and for sharing your question. It helped me to spot a flaw in the interoperability between Boost.Icl and Boost.DateTime, so I could fix it before boost 1.46. is released :)
Unfortunately this doesn't achieve what i want. This will deliver the "same" results as the contains() member from the time_period class. The underlying problem is that the reference points are specific instances of time. A ptime isn't just say one o'clock (1:00). A ptime is actually 1:00 on a specific day.
As Igor pointed out, the kind of time that you are looking for is probably boost::posix_time::time_duration. While posix_time::ptime is related to a fixed time origin (1400-Jan-01 00:00:00), the starting point of a time_duration can be chosen or is given by different points in time according to the program logic which it is used in, like in your daily schedules, the beginning 00:00 of some (not a specific) day.
So one could easily make a time range for a single day.
Using Boost.Icl you can do it this way:
time_duration start = hours(8) + minutes(30);
time_duration stop = hours(17) + minutes(15);
icl::interval
I was hoping for an easy way to have a time range for any day, or for a range of days (8:00 - 5:00 M-F).
Should be possible with icl::interval
I have ideas on how to extend the classes to achieve this. However, I was hoping this already existed.
Still, I appreciate the pointer to the interval class/library, I can envision usages for this in other areas of our code already.
That's nice to hear. I'd be happy if the Icl is useful for you. Best regards, Joachim -- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de