Boost logo

Boost :

From: Yitzhak Sapir (yitzhaks_at_[hidden])
Date: 2003-01-22 05:22:28


> From: Jeff Garland [mailto:jeff_at_[hidden]]
>
> > Hmmm while I can see your point, I still think a default
> constructor should
> > be provided. And as I, along with all of the users in the
> messages you cited
> > seemed to have expected that default constructed dates
> would be set to
> > 'not_a_date_time', I'd suggest that this would be the most
> sensible default
> > value. I don't see any point in *not* providing a default value.
>
> Keeping the interface to a minimum, preventing
> accidental/surprising values,
> avoiding the controversy of discussing what an appropriate value for
> the default constructor is. Well, 2 out of 3 anyway :-)
>
> But seriously I'm willing to add it, but I don't think I've heard
> a compelling use case yet...

I wrote a date formatting function. This function can take a datetime,
date, or time duration, and format it to text. The core however, is
implemented using datetime_t. The function implements the format
as described in Microsoft's documentation:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac10/html/acproFormatDate.asp

However, to implement format "General Date" (format letter "c"), I
need to know if the given input contains a date, a time, or a
datetime. Since the functions pretty much perform the same
thing, I have a core that implements functionality for datetime and
then I use this in the function that implements date/time separately.

However, to implement the no time I have to query whether the time
is 0:0:0.000. This is obviously problematic, since this is a
perfectly valid time. For the date, I don't even have a "start date" to
use. So I pass the core function a bool that tells it whether to ignore
the date, and pass in an arbitrary date when I want just the time.

It would be nicer, though, if I could just pass "not_a_date" or
"not_a_time". I could even expect the datetime function to throw
an exception if the requested format is for "month" and the
"not_a_date" was passed.

There is also a problem in serialization. A lot of serialization
systems first construct an empty struct, and then read in the
values. Doing it this way prevents serialization in those
systems of dates.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk