Thingaversary calculation error
ForumBug Collectors
Melde dich bei LibraryThing an, um Nachrichten zu schreiben.
1Helenliz
I knew my thingaversary was around now, but I wanted to check how many books I'm supposed to be buying.
LT seems a little confused on the subject:
I would have thought that it ought to be saying I have 1 day to my 11th thingaversary, not 365 to my 12th.
LT seems a little confused on the subject:
I would have thought that it ought to be saying I have 1 day to my 11th thingaversary, not 365 to my 12th.
2knerd.knitter
Ha! Probably a hardcoded check on 365 days is being confused by the leap year.
4Helenliz
Well something's changed for the better, it rightly thinks my thingaversary is today. >:-)
5MarthaJeanne
I missed mine. Oh, well.
6knerd.knitter
This is actually being caused by the fact that the numeric day of the year changes for all days after 2/29 in a leap year (e.g., March 1 is the 59th day of the year in non-leap years and the 60th day of the year in leap years); so we're checking if the numeric day of today is before your anniversary day. So if your anniversary was on March 1, then on February 29th, it's going to see both as the 59th day of the year and assume that means it needs to calculate to your next year's anniversary...
I'm not sure how we want to go about fixing this since it's such a corner case.
I'm not sure how we want to go about fixing this since it's such a corner case.
7MarthaJeanne
Except that it will jeep recurring every 4 years if you don't fix it.
8AnnieMod
>6 knerd.knitter: It is also the very first programming exercise when you are learning how conditionals work in a programming language... Not sure how exactly a leap year is "such a corner case" - throwing a "+1" in the calculation if you are after day 59 in a leap year should not be that hard, right? :)
PS: Does that mean that if someone joined on Feb 29, the site celebrates their anniversary on March 1? I am not sure if that is actually a bad idea - I am more curious than anything else.
PS: Does that mean that if someone joined on Feb 29, the site celebrates their anniversary on March 1? I am not sure if that is actually a bad idea - I am more curious than anything else.
9knerd.knitter
I actually think that it would treat Feb 29 anniversaries as only happening in years that have Feb 29th. Because for checking if today is your anniversary it actually checks that the month/year match.
I'm aware that there are many ways to solve this, but the code is not straightforward and I don't want to break it. I think the issue only comes up on the day before your anniversary in a leap year (assuming you didn't also sign up in a leap year), which is why it was less noticeable.
I'm aware that there are many ways to solve this, but the code is not straightforward and I don't want to break it. I think the issue only comes up on the day before your anniversary in a leap year (assuming you didn't also sign up in a leap year), which is why it was less noticeable.
10knerd.knitter
I pushed a change for this which hopefully does not break the calculation for all thingaversaries.