# Boost :

From: Wolf, Frank (FrWolf_at_[hidden])
Date: 2004-03-23 06:16:02

Hi all,

maybe this has already been discussed here!?

I have a problem constructing an "time_period" object with a duration of
zero which seems to be a special case not handled properly in my opinion.

with zero duration is not possible; i.e. the duration is at least 1.
Whats the rationale to make construction of this special case possible then?
(see code sample). That means what's the rationale not to handle the
special case of a zero duration?

Please see the following sample code:
------------------------------------------------------------------------
{
// Contruct a time_period representing a whole day
ptime pToday(date(2004, 2, 29) );
time_period wholeDay(pToday, time_duration(24, 0, 0) );
std::cout << to_simple_string(wholeDay) << std::endl;

// Contruct a time_period representing just the next point of time
ptime pTomorrow(date(2004, 3, 1) );
time_period wholeDay2(pTomorrow, time_duration(0, 0, 0) );
std::cout << to_simple_string(wholeDay2) << std::endl;

// Our second period is not contained in the first one
if (wholeDay.contains(wholeDay2) != false)
std::cout << "Error" << std::endl;
}
------------------------------------------------------------------------

gives:

[2004-Feb-29 00:00:00/2004-Feb-29 23:59:59.999999] // Correct
[2004-Mar-01 00:00:00/2004-Feb-29 23:59:59.999999] // Wrong?
Error? // Wrong!!!

>From my understanding the second time_period is not contained in the
first one, but the design of the library gives such a result.

Wouldn't it make sense to change the definition of the "time_period" class
to handle the special case of a zero duration too? At least it should not
be possible to construct a "time_period" with zero duration!?
(But I would really favor a solution which regards a "ptime" equvalent to
the special case of a "time_period" with zero duration).

Regards,

Frank

*******************************************
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort den Absender und loeschen Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorised copying, disclosure or distribution of the contents in this e-mail is strictly forbidden.
*******************************************