[Lazarus] DateDif function needed

John Landmesser JohnML at online.de
Wed Nov 13 15:37:44 CET 2013


On 13.11.2013 14:02, waldo kitty wrote:
>
>> We don't need to invent the wheel again, because others have 
>> solutions for that!
>
> then why does this thread exist? O:)

I'll try to find what the usual way is to handle these problems: c++ 
Libraries for example?!


>
>
> i don't know as i do not have that book... but since you have the 
> three routines available, can you please post what they return for the 
> two cases above??

I don't have my test app anymore, changed it a lot last days to follow 
the discussion, but perhaps you have a look at my post from 12.11.2013,  
21:56

>
> [...]
>> Bart delivered code that calculates 29.02.2000 to 28.02.2001 = 1 Year.
>> And that looks reasonable to me!
>
> but it is not, not really... 29.02 only comes around once every four 
> years... 29.02.leapyear to 28.02.leapyear+1 is one day short of a 
> year... if you were born on 29.02.1960, have you celebrated your 
> birthday 13 or 53 times? :)

That depends on the country , you're living, see 
http://en.wikipedia.org/wiki/February_29#Births

>
>> Bart wrote:
>>> I would actually say that in this particular case the diff is 1 Year...
>>> (11 M + (28 days in feb in a non-leapyear = 1M) = 12M = 1 Y.
>> Soon we'll have working DateDiff function and my question will be 
>> answered in
>> the end!
>> Thanks guys!!
>
> i can, however, agree with the reasoning bart has given above... do 
> you agree with it? is that what you want to see?

I'm not the one to decide, but i need a function which provides widely 
accepted results!
I'll google again.

>
> which of the following is what you want to see??
>
> 2000-02-29 to 2001-02-28 is    0 yrs   11 mos   27 days (original)
>
> 2000-02-29 to 2001-02-28 is    0 yrs   11 mos   28 days  (bart's fix)
>
> 2000-02-29 to 2001-02-28 is    1 yrs    0 mos    0 days  (actually 
> desired?)
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20131113/64a860e1/attachment-0003.html>


More information about the Lazarus mailing list