How to represent underspecified Date in boost::date_time library?

Hi, recently I found boost::date_time is a great library to work with for temporal work. But now I have a problem for your help with or input. It looks like the constructor of 'date' has three parameters year, month, day. What about if I just want to construct a Date with 'year'?, because this is typical in text, like "In 1991, ...". Is this possilbe? If not, is there any way around this limitation? or even more, can I represent sth like "In the 21st century", or "the winter of 1998"? But now, for me it is important to represent dates like "1998", without any month or day mentioned. Thanks for your time.

On Wed, 11 Jul 2007 13:05:40 -0500, Martin Min wrote
Hi, recently I found boost::date_time is a great library to work with for temporal work. But now I have a problem for your help with or input.
It looks like the constructor of 'date' has three parameters year, month, day. What about if I just want to construct a Date with 'year'?, because this is typical in text, like "In 1991, ...".
Yep, there are 3 parameters....it really isn't a 'date' without these specifics.
Is this possilbe? If not, is there any way around this limitation?
No.
or even more, can I represent sth like "In the 21st century", or "the winter of 1998"?
There isn't a type to do this in the library, but you could certainly add your own.
But now, for me it is important to represent dates like "1998", without any month or day mentioned.
You can use gregorian::greg_year which is the first parameter to a date. I guess the real question is, what do you want to do with the partial data information. Jeff

Jeff: Thanks for your reply. First, by "You can use gregorian::greg_year which is the first parameter to a date", do you mean a date can be constructed by just passing greg_year? or still I have to provide a month and day? I am working in Natural Language Understanding area, in which underspecifed Temporal Expressions abound in typical news text, and reasoning on these type of knowledge often has to deal with incomplete information. The granularity (or resolution) of time often changes in a discourse, sometimes year, or month, or date, or time, even century. What I like most boost::date_time are the various arithematic operations on durations and date periods, and timezone support. Of course, as well as the robustness. Probably, what I can do is to define another Date class, which have the boost::date_time::date has a member, and add members I may need? Thanks, Martin On 7/11/07, Jeff Garland <jeff@crystalclearsoftware.com> wrote:
On Wed, 11 Jul 2007 13:05:40 -0500, Martin Min wrote
Hi, recently I found boost::date_time is a great library to work with for temporal work. But now I have a problem for your help with or input.
It looks like the constructor of 'date' has three parameters year, month, day. What about if I just want to construct a Date with 'year'?, because this is typical in text, like "In 1991, ...".
Yep, there are 3 parameters....it really isn't a 'date' without these specifics.
Is this possilbe? If not, is there any way around this limitation?
No.
or even more, can I represent sth like "In the 21st century", or "the winter of 1998"?
There isn't a type to do this in the library, but you could certainly add your own.
But now, for me it is important to represent dates like "1998", without any month or day mentioned.
You can use gregorian::greg_year which is the first parameter to a date. I guess the real question is, what do you want to do with the partial data information.
Jeff _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

On Wed, 11 Jul 2007 13:34:22 -0500, Martin Min wrote
Jeff: Thanks for your reply. First, by "You can use gregorian::greg_year which is the first parameter to a date", do you mean a date can be constructed by just passing greg_year? or still I have to provide a month and day?
What I mean is you can just use greg_year to represent the year instead of the date class. However, given your requirements below it probably won't be of much help.
I am working in Natural Language Understanding area, in which underspecifed Temporal Expressions abound in typical news text, and reasoning on these type of knowledge often has to deal with incomplete information. The granularity (or resolution) of time often changes in a discourse, sometimes year, or month, or date, or time, even century.
I see.
What I like most boost::date_time are the various arithematic operations on durations and date periods, and timezone support. Of course, as well as the robustness.
Probably, what I can do is to define another Date class, which have the boost::date_time::date has a member, and add members I may need?
Possibly. It seems like you might need something a bit different -- a multi-resolution time point. Or you need to have series of different time points with different resolutions. For example you could have something like this: boost::gregorian::date; //time point with 1 day resolution class month_year; //time point with 1 month resolution class quarter; //time point with 3 month resolution class year; //time point with 1 year resolution class decade; //time point with 10 year resolution class century; //time point with 100 year resolution So, simple usage would look something like: month_year my(2007, Jul); quarter q(2007, 2); year y(2007) decade d(21, 1); //21st century, 1st decade .... Of course the alternative is to have a single type that provides the something like this: //pseudo code class general_time_point { enum TIMEPOINT_RESOLUTION { DAY, MONTH, YEAR, QUARTER, DECADE, CENTURY} general_time_point(year, month, day); general_time_point(year, month); general_time_point(value, TIMEPOINT_RESOLUTION); //general constructor }; So if you had one of these 2 kinds of types, what would you like to do with them? There a conceptual issues w.r.t the meaning of arithmetic operations on these kinds of types. For example: decade c(21, 1); c += days(1); //meaningless year y(2007) y += years(2); //ok The advantage of the multi-type solution is that the meaningless operations can be prevented at compile time. However, the multi-type solution is likely more difficult in your particular case. Jeff

Thanks, Jeff. Your proposals make sense and I will think more on this. Martin On 7/11/07, Jeff Garland <jeff@crystalclearsoftware.com> wrote:
On Wed, 11 Jul 2007 13:34:22 -0500, Martin Min wrote
Jeff: Thanks for your reply. First, by "You can use gregorian::greg_year which is the first parameter to a date", do you mean a date can be constructed by just passing greg_year? or still I have to provide a month and day?
What I mean is you can just use greg_year to represent the year instead of the date class. However, given your requirements below it probably won't be of much help.
I am working in Natural Language Understanding area, in which underspecifed Temporal Expressions abound in typical news text, and reasoning on these type of knowledge often has to deal with incomplete information. The granularity (or resolution) of time often changes in a discourse, sometimes year, or month, or date, or time, even century.
I see.
What I like most boost::date_time are the various arithematic operations on durations and date periods, and timezone support. Of course, as well as the robustness.
Probably, what I can do is to define another Date class, which have the boost::date_time::date has a member, and add members I may need?
Possibly. It seems like you might need something a bit different -- a multi-resolution time point. Or you need to have series of different time points with different resolutions. For example you could have something like this:
boost::gregorian::date; //time point with 1 day resolution class month_year; //time point with 1 month resolution class quarter; //time point with 3 month resolution class year; //time point with 1 year resolution class decade; //time point with 10 year resolution class century; //time point with 100 year resolution
So, simple usage would look something like:
month_year my(2007, Jul); quarter q(2007, 2); year y(2007) decade d(21, 1); //21st century, 1st decade ....
Of course the alternative is to have a single type that provides the something like this:
//pseudo code class general_time_point { enum TIMEPOINT_RESOLUTION { DAY, MONTH, YEAR, QUARTER, DECADE, CENTURY} general_time_point(year, month, day); general_time_point(year, month); general_time_point(value, TIMEPOINT_RESOLUTION); //general constructor };
So if you had one of these 2 kinds of types, what would you like to do with them? There a conceptual issues w.r.t the meaning of arithmetic operations on these kinds of types. For example:
decade c(21, 1); c += days(1); //meaningless year y(2007) y += years(2); //ok
The advantage of the multi-type solution is that the meaningless operations can be prevented at compile time. However, the multi-type solution is likely more difficult in your particular case.
Jeff _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

On 11/07/07, Martin Min <lingvisa@gmail.com> wrote:
It looks like the constructor of 'date' has three parameters year, month, day. What about if I just want to construct a Date with 'year'?, because this is typical in text, like "In 1991, ...".
For me it is important to represent dates like "1998", without any month or day mentioned.
"In 1991" just means somewhere in [ 19910101T000000, 19920101T000000 ), so perhaps you can deal in ranges of dates instead?

yeah, that's the interval-based representation and interpretation. On 7/11/07, Scott McMurray <me22.ca+boost@gmail.com> wrote:
On 11/07/07, Martin Min <lingvisa@gmail.com> wrote:
It looks like the constructor of 'date' has three parameters year, month, day. What about if I just want to construct a Date with 'year'?, because this is typical in text, like "In 1991, ...".
For me it is important to represent dates like "1998", without any month or day mentioned.
"In 1991" just means somewhere in [ 19910101T000000, 19920101T000000 ), so perhaps you can deal in ranges of dates instead? _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Martin Min Sent: Wednesday, July 11, 2007 8:06 PM Subject: [boost] How to represent underspecified Date in boost::date_timelibrary?
day. What about if I just want to construct a Date with 'year'?, because this is typical in text, like "In 1991, ...".
Is this possilbe? If not, is there any way around this limitation?
or even more, can I represent sth like "In the 21st century", or "the winter of 1998"?
But now, for me it is important to represent dates like "1998", without any month or day mentioned.
Wouldn't date_period fit your needs here? cheers, aa -- Andreas Ames | Programmer | Comergo GmbH | ames AT avaya DOT com Sitz der Gesellschaft: Stuttgart Registergericht: Amtsgericht Stuttgart - HRB 22107 Geschäftsführer: Andreas von Meyer zu Knonow, Udo Bühler, Thomas Kreikemeier
participants (4)
-
Ames, Andreas (Andreas)
-
Jeff Garland
-
Martin Min
-
Scott McMurray