TLDR Dev · LAUNCHES & TOOLS

A VERY FAST 64–BIT DATE ALGORITHM: 30–40% FASTER

benjoffe.com15 min read

Summary from the TLDR Dev newsletter

This article presents a very fast date conversion algorithm that provides accurate results over a period of ±1.89 trillion years. The algorithm uses only 4 multiplications, compared to other fast date algorithms, which have always used 7 or more expensive computations. It calculates years backwards, which removes various intermediate steps. The algorithm uses a year-modulus-bit shift technique to calculate day-of-year, removing a division. It uses the 'Julian Map' technique to speed up 100/400 year calculation, removing two more hardware multiplications.