CSC207 - Project 1
This Day in History

Assigned September 17th 2 p.m.
Due September 26th 2 p.m.


Overview

Many systems have been devised over the years for keeping time. In this project, you will explore some of the oddities present in our current calendar system by using a formula to calculate the day of the week for any given day between 1700 and 2299.

In particular, this project will cover the following concepts we have discussed in class:

Description

Over the centuries, our calendar has been realigned many times to coincide with growth in our astronomical knowledge. Incorporating elements of both the solar and lunar cycle, the current international standard calendar is the Gregorian Calendar, first adopted in 1582. There are seven days a week due to religious influence, 12 months to a year in honor of the lunar cycle, and 365 days a year in relation to the earth's orbital period around the sun, with enough leap days included to properly align the system with the true orbital period of approximately 365.242190419 days. While better than the Egyptian and Roman calendars in use at the time of adoption, it is still an approximation with room for improvement, from the more-precise Iranian Calendar to a standardized and perpetual World Calendar.

One of the more interesting quirks of the Gregorian Calendar is that each year can start on a different day of the week, since 365 is not a multiple of 7. But there is a simple algorithm (based on the Doomsday Rule) that you can memorize to find the day of the week for any date between Jan 1st, 1700 and Dec 31st, 2299:

  1. Find the last 2 digits of the year. Divide this by four (using integer division) and sum these two together to get y.
  2. Get the corresponding offset (shown below) for the month for m.
  3. Take the day to get d
  4. Add y, m and d together to find dow.
  5. Add the year offset (also shown below) to dow.
  6. If the year is a leap year and the month is January or February, subtract 1 from dow.
  7. dow mod 7 corresponds to the day of the week. (0 = Sunday, 1 = Monday, 2 = Tuesday, etc.)
Table for Month Offset

JanFebMarAprMayJun JulAugSepOctNovDec
622503 514624

Table for Year Offset

170018001900200021002200
5310-2-4

For example, if you wish to know the day of the week for September 17th, 2008, these are the steps you would take:
  1. 8 + 2 = 10
  2. 4
  3. 17
  4. 10 + 4 + 17 = 31
  5. 31 + 0 = 31 (offset code = 0)
  6. 31 + 0 = 31 (leap year, but not Jan or Feb)
  7. 31 % 7 = 3 for Wednesday

Leap Year Rule

Under the Gregorian Calendar, a year is a leap year (such that February has 29 days) if it is a multiple of four, except when it is also a multiple of 100 but not 400. So, 1900 and 2100 are not leap years, but 2000 is a leap year.

Coding

For this assignment, you will write a Python program called date_finder.py. This program will first tell the user about the program, and then take as input from the user the date they wish to use for finding the day of the week. This input must ask for year first, followed by month, followed by day, where each is entered as an integer number.

With correct input, your program will then parse this input into the day, month and year, follow the above algorithm to compute the day of the week, and output this to the user in the following format (using September 17th, 2008 as an example):

Sep 17, 2008 will fall on Wed.

For the day of the week, use the standard three-letter abbreviation for that day, such that Monday is "Mon", Tuesday is "Tue", etc.

Testing

Test your code on the following dates to ensure you are getting the right answers. I will be using other dates to test your project for grading, so you should also find other dates than these for your own testing.

Restrictions

For this project, you are not allowed to use if - then - else blocks for making decisions. Determining if a year is a leap year may be difficult this way, but is not impossible, especially since your end result is know if you should subtract one from your calculation.

You also may not use lists to store data. You should use only Strings. This will be possible if you make all of your stored information of equal width within each table.

What to Hand In

Log in to cs.centenary.edu through either Secure FTP or WinSCP using your cs login and password. Create a subdirectory from csc207 called project1. Copy your date_finder.py project into this directory. Make sure you have followed the Python Style Guide, and have run your project through the Automated Style Checker.

You must hand in:


© Mark Goadrich 2008, Centenary College of Louisiana