Tony Finch revisits and improves his classic algorithm for converting Gregorian dates to Julian Day numbers (rata die), the core logic behind C's mktime() function. He incorporates optimizations learned from Ben Joffe, including a 5-month repeating pattern that aligns naturally with leap day boundaries when months are counted from March.
Background
The Gregorian-to-Julian Day number conversion is a classic algorithm used in many programming languages and libraries for date arithmetic. The formula discussed is closely related to the one used in C's standard library mktime() function.
- Source
- Lobsters
- Published
- Aug 9, 2026 at 10:32 AM
- Score
- 5.0 / 10