|
Boost Users : |
From: Paul Giaccone (paulg_at_[hidden])
Date: 2006-06-27 13:17:49
Jason Dolan wrote:
> I'm trying to get the age of someone in Years and/or months and/or days.
>
> I've tried:
>
> date_period dp(day_clock::local_day(), birthdate);
> cout << "You are " << dp.length() << " old" << endl;
>
> But that only calculates days. Is there a static function available
> that will turn days into months. and days into years?
>
I don't know the answer to that question, but it would have to be a
function of not only the age in days but also the birth date.
A person born on 1 January 2003 is 365 days old on their first birthday,
while someone born on 1 January 2004 is 366 days old on their first
birthday. On their first birthdays, each of them is a year old, but the
second person is a day older than the first. So simply dividing by 365
and using the remainder for the days in the part-year would not be
sufficient.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net