====== what year might that have been? ====== > Given an invitation for an event on "Saturday, April 26th," for instance, might it (if correct, of course) have been from last year? Without consulting a perpetual calendar((phone books and almanacs used to have those, but I don't know where I'd look for one today without using a search engine on the Internet)), here's one solution that uses a sort of back of the envelope perpetual calendar that is easy to construct. ===== The Principle of the Method ===== The idea is to figure out what day of the week January 1 had to fall in order for your date to fall on the right day of the week; for dates after February, two weekdays will be possible, one for leap years and one for other years. Then, figure out which years started that way; that is easy to do from the calendar of the current year (or a good memory). - calculate how many days came before your date (including January 1). - calculate the remainder modulo 7 to get the weekday difference between January 1 and your date. - build the table of January 1 weekdays. - look up the possibilities. ===== Date Serial Number ===== The serial number for a date can be computed as the sum of month lengths of prior months in the year plus date minus 1. ==== Example ==== ^ Month ^ Non-leap ^ Leap ^ | January (all) | 31| 31| | February (all) | 28| 29| | March (all) | 31| 31| ^ s/total | 90| 91| | April (date) | 26| 26| ^ total | 116| 117| ^ minus 1 (total prior days) | 115| 116| ^ modulo 7 | 3| 4| What this means is that April 26 falls some number of weeks plus either 3 or 4 days after January 1. Thus, if April 26th were a Saturday, January 1 must have been either a Wednesday (non leap year, 3 days before Saturday) or a Tuesday (leap year, 4 days before Saturday). To compute "modulo 7" just divide by seven and keep the remainder: 115 = (7 * 16) + __3__ . ===== Mini Perpetual Calendar ===== Now we need to know what weekday January 1 fell (or will fall) in each year! Here's a table with the answers, but it is pretty easy to reconstruct if you don't have it at hand. * The year after a leap year starts two weekdays later than the leap year did, * otherwise a year starts one weekday later than the previous year did. * It repeats after 28 years (7 rows). So starting with Sunday in 2012, we can easily construct this table: ^ When ^ Year ^ Year+1 ^ Year+2 ^ Year+3 ^ ^ 2012 | Sun | Tue | Wed | Thu | ^ 2008 | Tue | Thu | Fri | Sat | ^ 2004 | Thu | Sat | Sun | Mon | ^ 2000 | Sat | Mon | Tue | Wed | ^ 1996 | Mon | Wed | Thu | Fri | ^ 1992 | Wed | Fri | Sat | Sun | ^ 1988 | Fri | Sun | Mon | Tue | Done! ==== Example (continued) ==== When has there been Saturday, April 26? When have there been leap years starting on Tuesday or other years starting on Wednesday? ^ When ^ Year ^ Year+1 ^ Year+2 ^ Year+3 ^ ^ 2012 | Sun | Tue | __Wed__ | Thu | ^ 2008 | __Tue__ | Thu | Fri | Sat | ^ 2004 | Thu | Sat | Sun | Mon | ^ 2000 | Sat | Mon | Tue | __Wed__ | ^ 1996 | Mon | __Wed__ | Thu | Fri | ^ 1992 | Wed | Fri | Sat | Sun | ^ 1988 | Fri | Sun | Mon | Tue | * Answer: 2008, 2003, 1997, * Also 28, 56, 84 (etc.) years prior: 1980, 1975, 1969, 1952, 1947, 1941 (etc.)