[Lazarus] *** GMX Spamverdacht *** Re: DateDif function needed

Jürgen Hestermann juergen.hestermann at gmx.de
Sat Nov 16 19:36:00 CET 2013


Am 2013-11-16 18:40, schrieb Michael Van Canneyt:
> Start with D1. Call this D.
> Keep adding 1 to year of D till your jumps over D2. If you jumped over, substract 1 from year.
> Keep adding 1 to month of D till D jumps over D2. If you jumped over, substract 1 from month.
> Keep adding 1 to day of D till D reaches D2.
>
> The number of years, months, days you thus added is the period. I may fiddle a bit with the definition of "jumps over" and "reaches", but essentially that is it.
>

That sounds very reasonable and is actually the rationale behind this kind of calendar diff function.
I don't thing that anything needs to be changed to this algorithm.

So from 28.2. of a year to 29.2. of the next (leap) year is then 1 year plus 1 day
and from 29.2. to 28.2. is not a full year (11 months + 28 days)!
That's how it would be defined and I can't think of anything that makes more sense here.




More information about the Lazarus mailing list