rsjtdrjgfuzkfg / thunderbird-birthdaycalendar

Thunderbird add-on to display birthdays from the address book in the calendar
Mozilla Public License 2.0
21 stars 5 forks source link

Age calculation for one year picks last year #10

Closed rsjtdrjgfuzkfg closed 2 years ago

rsjtdrjgfuzkfg commented 3 years ago

This was originally reported in #9.

STR:

  1. Install Birthday Calendar 1.0 after adding at least one contact with a birthday in any version of Thunderbird 78
  2. Set the number of years to calculate the age for to 1
  3. Look in the calendar

Expected: Birthdays in the current year are displayed with an age, birthdays in other years not.

Actual: Birthdays in the last year are displayed with an age, birthdays in other years not.

tinutac commented 3 years ago

I've taken a look at that also. I'm not sure I fully understand why you use for the start year: now.getFullYear() - Math.ceil(settings.yearsToDisplayAgeFor / 2); on line 44 in provider.js. Am I missing something?

If you the start year is now.getFullYear() it seems to work as intended.

tinutac commented 3 years ago

Ah... I've now read some of the closed issues. If I understand correctly, the idea is that the interval is actually split half based on the current date? Which means that for a year it should do -6 months/ + 6 months? My reasoning was that 1 year means current year, 2 years means current + next, etc.

rsjtdrjgfuzkfg commented 3 years ago

The interval is split in half if it is even, and almost in half when it is not (the interval is tied to calendar years, so sub-year things are not calculated).

As it is more common to dig far into the past than to dig far into the future, I used ceil to push the "extra" year when dealing with odd values to the past. But one year is also odd so this is not working as one would usually expect for a single year ;)

Honestly never tested that case, I assumed that people either don't want ages (= set to zero) or want ages (= set to something large enough that they never see birthdays without age, which depends on how long they need to access past entries and how far they plan ahead). But there has been quite a lot of confusion regarding this option (as you see in other issues), so I'm considering to change it into two separate settings (how far back / how far ahead) or otherwise make it clearer what the option is for.

That's why I did not immediately fix this trivial bug.

tinutac commented 3 years ago

I didn't really think about that. I'm a person that looks rather into the future :-) Basically you'll have that issue with all odd intervals or you should dig into months which complicates the things a little bit. I'll take a look into it.