Using Simple Linear Models with Truncation to Determine the Gregorian Day of the Week
Bryce Iversen
TL;DR
The paper introduces a table-free algorithm to compute the day of the week in the Gregorian calendar by marrying a simple truncation-driven linear model with modulo arithmetic. Central to the method are the components $L(y)$ for leap-year accumulation, $D(y,m,d)$ for days into the year, and a final closed-form for $W(y,m,d)$ that yields the weekday after combining these terms with the epoch offset. Through two worked examples, the approach demonstrates correct weekday determination for dates spanning modern and recent history, while situating itself among classical formulas like Zeller’s congruence. The work emphasizes a minimal-memory, regression-based strategy to a perpetual calendar, with potential extensions to related calendar systems in future work.
Abstract
The Gregorian calendar -- first established for daily use on Friday, October 15th, 1582 by Pope Gregory XIII in Catholic countries -- is presently the most pervasive calendar in the world. As such, algorithms for performing various calendrical computations in accurate, performant, and easily implementable ways are extremely useful in fields like software engineering. In this paper, we present a novel algorithm for determining the day of the week for any date in the Gregorian calendar. Of note, our algorithm does not rely on remembering tables of values. Instead, we encode tables needed for computation using simple linear regression with truncation to adjust for any errors present in our linear models in such a way that no tables have to be recalled. In addition, our algorithm does not require a relabeling of days, weeks, months, or years to values other than their intuitive representations. The algorithm works by taking a date in the Gregorian calendar, calculating the number of days (accounting for leap years using simple linear regression with truncation) that have elapsed since the epoch of the Gregorian calendar in 1582 from the specified date and adding this number modulo 7 to the epoch's day of the week thus, obtaining the day of the week for the requested date in numeric form.
