[datetime] little problem with periods
Hello, i am using Boost V1.5.8 under vs 2010 with a german windows 7 64 bit. When I tried to calculate a time period I always ran into the same problem. The period is calculated one day too short. I wrote a little program to illustrate my problem. It's important that you change the value of the variable test to the current date. Is this a bug or do I use the library in an incorrect way? Thanks a lot, Georg #include "boost/date_time.hpp" #include <iostream> using namespace std; using namespace boost::gregorian; int main() { date today = day_clock::local_day(); date test(2015,6,23); // Change value to current date date first(1965,10,26); date_period period(first, today); if (!period.contains(test)) cout << "shouldn't be our testdate in the period? " << endl; }
On June 23, 2015 7:42:03 AM EDT, Georg.Kellerer@lfu.bayern.de wrote:
Hello,
i am using Boost V1.5.8 under vs 2010 with a german windows 7 64 bit. When I tried to calculate a time period I always ran into the same problem. The period is calculated one day too short. I wrote a little program to illustrate my problem. It's important that you change the value of the variable test to the current date. Is this a bug or do I use the library in an incorrect way?
Thanks a lot, Georg
#include "boost/date_time.hpp" #include <iostream> using namespace std; using namespace boost::gregorian;
int main() { date today = day_clock::local_day(); date test(2015,6,23); // Change value to current date date first(1965,10,26); date_period period(first, today);
Is date period a boost function or one of your own?
if (!period.contains(test)) cout << "shouldn't be our testdate in the period? " << endl; }
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Sent from my Android device with K-9 Mail. Please excuse my brevity.
On Tue, 23 Jun 2015 13:42:03 +0200,
Hello,
i am using Boost V1.5.8 under vs 2010 with a german windows 7 64 bit. When I tried to calculate a time period I always ran into the same problem. The period is calculated one day too short. I wrote a little program to illustrate my problem. It's important that you change the value of the variable test to the current date. Is this a bug or do I use the library in an incorrect way?
The end of the period is not considered part of the period (see http://theboostcpplibraries.com/boost.datetime-calendar#ex.datetime_08 or http://dieboostcppbibliotheken.de/boost.datetime-kalenderdaten#ex.datetime_0... if you prefer German). HTH, Boris
[...]
On 6/23/15 8:46 AM, Boris Schäling wrote:
On Tue, 23 Jun 2015 13:42:03 +0200,
wrote: Hello,
i am using Boost V1.5.8 under vs 2010 with a german windows 7 64 bit. When I tried to calculate a time period I always ran into the same problem. The period is calculated one day too short. I wrote a little program to illustrate my problem. It's important that you change the value of the variable test to the current date. Is this a bug or do I use the library in an incorrect way?
The end of the period is not considered part of the period (see http://theboostcpplibraries.com/boost.datetime-calendar#ex.datetime_08 or http://dieboostcppbibliotheken.de/boost.datetime-kalenderdaten#ex.datetime_0... if you prefer German).
HTH, Boris
One way to think of it is that the date 2015-06-01 means the point in time 2015-06-01 00:00:00, so if that is the end point of a period, the day isn't included. -- Richard Damon
participants (4)
-
Boris Schäling
-
Georg.Kellerer@lfu.bayern.de
-
Michael
-
Richard Damon