Christopher Pisz
unread,Apr 24, 2015, 2:35:18 PM4/24/15You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
The problem I am trying to solve is that I need to determine if any
given datetime falls within a certain scheduled week.
I am already using boost::posix_time::ptime in my project. I thought it
would be natural to use boost::posix_time::time_period and its
boost::posix_time::time_period::contains method.
However, it seems fruity... I wrote the following test:
// Boost Includes
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
// Standard Includes
#include <iostream>
#include <ostream>
#include <memory>
#include <vector>
int main()
{
boost::posix_time::ptime start(boost::gregorian::date(2015, 4, 24),
boost::posix_time::time_duration(0,
0, 0));
boost::posix_time::ptime end(boost::gregorian::date(2015, 4, 24),
boost::posix_time::time_duration(11,
59, 59));
boost::posix_time::time_period period(start, end);
if( period.contains(start) )
{
std::cout << "Start is Inclusive\n";
}
else
{
std::cout << "Start is Exclusive\n";
}
if( period.contains(end) )
{
std::cout << "End is Inclusive\n";
}
else
{
std::cout << "End is Exclusive\n";
}
}
and the output says the start is inclusive and the end is exclusive.
Seems very odd to me. Was there something wrong with my thinking?
Also, is there some alternative in the standard, and is that standard
available in msvc11?
--
I have chosen to troll filter/ignore all subthreads containing the
words: "Rick C. Hodgins", "Flibble", and "Islam"
So, I won't be able to see or respond to any such messages
---