How Gramps calculates ages?

Hi.

I am writing to inquire about how Gramps calculates the ages of individuals displayed in the individual detail window. In this particular instance, Gilbert was born on October 6, 1831, and passed away on April 14, 1895. His actual age at the time of his death was 63 years, 6 months, and 8 days. However, Gramps displays his age as 64 years.

I believe it would be more accurate to display the truncated age (63 years, 11 months, 29 days → 63 years) instead of the rounded age. This aligns with how ages are typically expressed in official documents and personal conversations, where individuals state their age as the number of years they have completed up to the day before their birthday.

For example, I would say I am 30 years old until the day before my birthday.

I kindly request that you consider implementing this change to display truncated ages in the individual detail window, providing a more accurate and consistent representation of individuals’ ages.

Thank you for your attention to this matter.

Note : I use Gramps 5.1.6 on Debian

2 Likes

You can customise your copy of Gramps yourself.

The computation is in file gramps/gen/lib/date.py. Look for method _format around line 400 (exact line number depends on Gramps version; on the one I’m modifying, it is line 410.

About 20 lines down, you have:

if self.precision == detail:
    if diff_tuple[1] >= 6: # round up years
        # translators: leave all/any {...} untranslated
        retval = ngettext("{number_of} year", "{number_of} years",
                          diff_tuple[0] + 1
                         ).format(number_of=diff_tuple[0] + 1)
    return retval     

Comment out the 5 lines starting with if diff_tuple[1] >= 6 or delete them. Don’t remove the return retval statement !

Since things may go awry, make first a copy of the file so that you can restore it if you messed up.

1 Like

In 5.2, you can do this in preferences:
Edit->Preferences->Data and use the “Round the year” option.

3 Likes

@pgerlier
Thank you very much. It works and I have the age display the way I want it. I took care to edit the file with sudo rights and to make a copy beforehand.

@SNoiraud
This is great information that will simplify my use when I upgrade to 5.2. I’d like to thank the developers who added this feature, which will be very useful to me. For the time being, however, I’m forced to stick with 5.1.6 because 5.2 isn’t yet in the Debian repositories.