Statistics: Age calculation wrong at "Oldest living people"

Bug #1166054 reported by Sunday
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
webtrees
Triaged
Wishlist
Unassigned

Bug Description

Today (08.04.2013) is the first birthday of my son but the statistic of "Oldest living people" shows an age of 11 months for him and to the expected 12 months or at least 1 year.

description: updated
description: updated
Revision history for this message
ToyGuy (toyguy) wrote :

Where is your server located? Is it possibly in a different time zone?

Changed in webtrees:
status: New → Incomplete
Revision history for this message
Sunday (magic-sunday-deactivatedaccount) wrote :

The server is on my NAS. There is no time zone difference.

Changed in webtrees:
status: Incomplete → New
Revision history for this message
Sunday (magic-sunday-deactivatedaccount) wrote :

The age calculation inside _topTenOldestAlive is wrong. As the age in days is 365 but the calculation is by dividing through 365.25 (i think because of leap years) the final result is less than 1 so the age is 11months not 1 year as it should be.

if ((int)($age/365.25)>0) {
    $age = (int)($age/365.25).'y';
} else if ((int)($age/30.4375)>0) {
    $age = (int)($age/30.4375).'m';
} else {
    $age = $age.'d';
}

Revision history for this message
fisharebest (fisharebest) wrote :

webtrees works with a number of different calendars.

One's age can be different, depending on which calendar one uses. It is possible for someone to be 51 years old (gregorian), 52 years old (jewish) and 53 years old (arabic) at the same time.

Hence you may have someone aged 52 who is older than someone who is aged 53 (!)

The calendar calculations are quite complex, and hence quite slow.

The statistics make a number of simplications to allow them to improve performance. The "solar year" approximation is one of them. You'll see it throughout the Stats.php module.

In this particular case, it should be possible to calculate the "calendar" age (rather than the solar-year age"), as this is done after the "heavy lifting" part.

Changed in webtrees:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Sunday (magic-sunday-deactivatedaccount) wrote :

I added a possible patch for the Stats.php to fix the calculation.

Revision history for this message
fisharebest (fisharebest) wrote :

The patch uses hard-coded rules for gregorian calendars (e.g. 12 months in a year). The jewish calendar can have 13 months in some years.

Any solution will need to use the existing calendar library functions.

Revision history for this message
kiwi (kiwi3685-deactivatedaccount) wrote :

I don't believe it is necessary to "fix" this.

Statistics are only ever meant to be an approximation, not an exact measure. The more accurate you try to make them, the more problems you create.

The example quoted in this bug report is a rare / uncommon situation. I can't imagine many family trees where the oldest living individual is (about) 1 yr old.

I recommend the status of this bug be changed to either "invalid" or "will not fix".

(By the way, I not that "sunday" / "sonntag" posted the same "bug" on the PGV bug list. That will, if responded to at all, get the same answer, as the code is or was identical).

Revision history for this message
Sunday (magic-sunday-deactivatedaccount) wrote :

As its a bug it should be fixed. Sure its not a big bug and there is maybe a lot of other stuff to be done.

The problem exists for nearly everyone:
    19 year old person * 365 days per year + appr. 4 leap year days = 18,99794 => Display: 18y

Revision history for this message
wooc (wooc) wrote :

Sunday as you can see in #3 the age ($age) is in days. The bug NOT exists for nearly everyone. You can see it only on a specific day (probably birthday) and, I think, only once in 4 years period. So the bug exists extremely rarely.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.