-
Notifications
You must be signed in to change notification settings - Fork 3.5k
calculate date_from_iso_days using neri_schneider algorithm #14999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
calculate date_from_iso_days using neri_schneider algorithm #14999
Conversation
|
|
||
| days_in_previous_years(year) + days_before_month(month) + leap_day_offset(year, month) + day - | ||
| 1 | ||
| y = if month <= 2, do: year - 1, else: year |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could mention the name of the algorithm in a comment with a link for future reference?
|
Was very intrigued, took a look and stumbled across this recent article claiming to surpass Neri-Schneider. A New Faster Algorithm for Gregorian Date Conversion - also note the mention of an even faster version by now. It might be of interest, if not, apologies for the noise :) |
Same here: this new algorithm made me curious how we do it. :) The mentioned algorithm from last week is implemented in c and uses compiler tricks that can't be implemented on the beam: like bit shifting a 128bit number by 64bits that is 'free' on modern computers. |
|
here a benchmark for the function date_to_iso_days: |
|
💚 💙 💜 💛 ❤️ |
This is a faster implementation than the erlang one. The reference implementation is mit licensed I adjusted it for elixir needs using windsurf with claude opus.
2x speedup comparing to the version from last week.