On Mon, Feb 28, 2005 at 05:43:52PM +0100, Sven Ingebrigt Ulland wrote:
> On Mon, Feb 28, 2005 at 07:43:47AM -0800, Hill, Ronald wrote:
> > Sven Ingebrigt Ulland wrote:
> > > For some time now, I've been trying to figure out how
> > > to calculate how many days left before a given date
> > > of birth, to easily keep track of my friends' birthdays.
> 
> Here is a step by step example for when this approach might
> fail (mostly for my understanding):
> 
> Today = 2007-03-02
> DOB   = 1981-03-01 #Date of birth.
> 
> First, we set the year of birth to this year:
> DOB   = 2007-03-01
> 
> Now, this date has already passed in this year, so we add a year:
> DOB   = 2008-03-01
> 
> Now, when we calculate the duration from Today to DOB, it will
> actually include the 29th of February since 2008 is a leap year,
> and thus miss by one day. Again, I might be totally off here;
> please comment.

I just realized how completely wrong I was. Of course it includes
the leap year, and it should! Actually, I've been thinking about
this problem in the wrong way all along. Please forgive my utter
ignorance here. Thanks again for the code, which I now believe to
be correct.

shameful regards,
Sven

Reply via email to