A Fast 64-Bit Date Algorithm (30–40% faster by counting dates backwards)
31–40 of 100 posts
Re: A Fast 64-Bit Date Algorithm (30–40% faster by counting dates backwards)
#32Earlier quoted context omitted.
I just added a link to the code with a brief comment. Basically, it simplifies the leap year date calculation. If February is the last month of the year, then the possibly-existing leap day is the last day of the year. If you do it the normal way your calculations for March through December need to know whether February is a leap year. Now none of that is needed. You don’t even need explicit code to calculate whether…
IIRC, it's also why the leap day was set to Feb 29th in the first place. At the time (romans?) the year started March 1st. In case someone was wondering why in the world someone said we should add a day to the second month of the year...
Re: A Fast 64-Bit Date Algorithm (30–40% faster by counting dates backwards)
#33Earlier quoted context omitted.
I just added a link to the code with a brief comment. Basically, it simplifies the leap year date calculation. If February is the last month of the year, then the possibly-existing leap day is the last day of the year. If you do it the normal way your calculations for March through December need to know whether February is a leap year. Now none of that is needed. You don’t even need explicit code to calculate whether…
IIRC, it's also why the leap day was set to Feb 29th in the first place. At the time (romans?) the year started March 1st. In case someone was wondering why in the world someone said we should add a day to the second month of the year...
Re: A Fast 64-Bit Date Algorithm (30–40% faster by counting dates backwards)
#34> The algorithm provides accurate results over a period of ±1.89 Trillion years i'm placing my bets that in a few thousand years we'll have changed calendar system entirely haha but, really interesting to see the insane methods used to achieve this
Given the chronostrife will occur in around 40_000 years (give or take 2_000) I somewhat doubt that
Re: A Fast 64-Bit Date Algorithm (30–40% faster by counting dates backwards)
#35I wrote my own date calculation functions a while ago. And during that, I had an aha moment to treat March 1 as the beginning of the year during internal calculations[0]. I thought it was a stroke of genius. It turns out this article says that’s the traditional way. [0]: https://github.com/kccqzy/smartcal/blob/9cfddf7e85c2c65aa6de...
not completely coincidentally, March was also the first month of the year in many historical calendars. Afaik that also explains why the month names have offset to them (sept, oct, nov, dec) edit: I just love that there are like 5 different comments pointing out this same thing
Everything now makes sense, I always wondered why September was the nine month with a 7 prefix.
Re: A Fast 64-Bit Date Algorithm (30–40% faster by counting dates backwards)
#36Earlier quoted context omitted.
IIRC, it's also why the leap day was set to Feb 29th in the first place. At the time (romans?) the year started March 1st. In case someone was wondering why in the world someone said we should add a day to the second month of the year...
And (oct)ober was the 8th month of the year, (nov)ember the ninth, (dec)ember the tenth!
Re: A Fast 64-Bit Date Algorithm (30–40% faster by counting dates backwards)
#37I wrote my own date calculation functions a while ago. And during that, I had an aha moment to treat March 1 as the beginning of the year during internal calculations[0]. I thought it was a stroke of genius. It turns out this article says that’s the traditional way. [0]: https://github.com/kccqzy/smartcal/blob/9cfddf7e85c2c65aa6de...
At this risk of me feeling stupid, could you briefly explain the benefit of this?
Re: A Fast 64-Bit Date Algorithm (30–40% faster by counting dates backwards)
#38I wrote my own date calculation functions a while ago. And during that, I had an aha moment to treat March 1 as the beginning of the year during internal calculations[0]. I thought it was a stroke of genius. It turns out this article says that’s the traditional way. [0]: https://github.com/kccqzy/smartcal/blob/9cfddf7e85c2c65aa6de...
not completely coincidentally, March was also the first month of the year in many historical calendars. Afaik that also explains why the month names have offset to them (sept, oct, nov, dec) edit: I just love that there are like 5 different comments pointing out this same thing
Re: A Fast 64-Bit Date Algorithm (30–40% faster by counting dates backwards)
#39Earlier quoted context omitted.
IIRC, it's also why the leap day was set to Feb 29th in the first place. At the time (romans?) the year started March 1st. In case someone was wondering why in the world someone said we should add a day to the second month of the year...
That's correct, the Romans had March as the first month of the year, so leap day was the last day of the year and September, October, November and December were the 7th (sept), 8th (oct), ninth (nov) and 10th (dec) months.
Re: A Fast 64-Bit Date Algorithm (30–40% faster by counting dates backwards)
#40Have a fallback with this algorithm for all other platforms.