Problem with day of year routine
Closed this issue · 2 comments
billybennett commented
The day of year routine gives the wrong values for days in May, July, October, and December (all are one too large). Ran the following dates:
Date:
- Jan 15 | 15 15
- Feb 23 | 54 54
- May 16 | 138 137
- Jul 4 | 187 186
- Oct 31 | 306 305
- Dec 25 | 360 359
- Dec 31 | 367 366
Issue is the value in the equation for tracking short months needs to be 27 instead of 23, ie
doy -= floor((4 * (date.getMonth() + 1) + 23) / 10);
should be
doy -= floor((4 * (date.getMonth() + 1) + 27) / 10);
If you have the extra day on purpose made up elsewhere, i apologize. I was looking for a javascript doy routine that didn't use (date2 - date1) / 86400000 and came across this one, realised Dec 31 was off by one and thought I'd share.
billybennett commented
My bad. Apologies, accidentally edited out the +1 to getMonth when I did the testing.
Scimonster commented
And this year is a leap year.
…On Fri, Jan 17, 2020, 7:51 AM billybennett ***@***.***> wrote:
Closed #79 <#79>.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#79?email_source=notifications&email_token=AAVSCETNCGFGPMIODY3P5DLQ6FBODA5CNFSM4KH5D742YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWBABAIA#event-2956988448>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAVSCESTYEINJFGOCAC2GBTQ6FBODANCNFSM4KH5D74Q>
.