3 ms·
That's amazing! Long time ago I wrote a conversion function that took longer than 10ns but had the input normalization feature you skipped in your blog post. (S
by kccqzy 3y ago
That's amazing! Long time ago I wrote a conversion function that took longer than 10ns but had the input normalization feature you skipped in your blog post. (Say January 32nd will be automatically transformed to February 1st, and specifying the thirteenth month of a year will become January of the following year.) Those are simple to implement and I doubt it costs much.
To normalize months outside of the 1–12 range:
--month;
if (month >= 12 || month < 0) {
year += month / 12;
month %= 12;
if (month < 0) {
--year;
month += 12;
}
}
++month;
To fix incorrect days that's even easier. Most algorithms do not need any changes.