WeekDay  ======= By D.M. Balean, August 1992  ### 30 ### 30 ### 30 ### 30 ### 30 ### 30 ### 30 ### 30 ### 30 ### 30 ### For your education! =================== I came across an interesting problem. Given a certain date, how can that date's weekday be deduced? I decided to get my computer to tell me. First a little research was needed. -------------- Ancient Times -------------- In ancient times, the Romans used a lunar calendar. It had three special days, Kalendae, Nonae, and Ides. Kalendae was the first day of the month. There was a variable number of days between Kalendae and Nonae. These days were called the xth day before Nonae. Nonae itself was the ninth day before Ides. Ides was supposed to be the Full Moon and was the exact middle of the month. Ides was derived from the Latin word "iduare" meaning to divide. From Ides on, the days were called the xth day before Kalendae, that is, before the first of the next month. Now, the xth day before whatever was not how we understand it. The Romans had a rather strange numeric system: I, II, III, IV, V, VI, VII, VIII, IX, X = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 Where is zero represented? I think this is where things really started to go wrong! Nonae, for example, was by our reckoning 8 days before Ides, not 9 as they thought. Ides was actually 8 days after Nones.... The same applied to their whole system. The Romans used inclusive numbering and it was back to front. WHAT A GHASTLY SYSTEM! -------------- Julius Caesar born 100 B.C., died 44 B.C. -------------- Enter Julius Caesar. He realized the problem and got the advice of an Alexandrian astronomer called Sosigenes. Sosigenes suggested using the solar year and estimated it at 365.25 days which wasn't actually quite correct. The Julian calendar started at 45 B.C., 2 years before Julius Caesar was murdered by Brutus & Co. The year 46 B.C. was given an extra 90 days and what would have been the beginning of March became 1st January of what is now known as 45 B.C. --------- Augustus --------- Unfortunately the Romans didn't understand simple arithmetic. Although their previous system was incomprehensible to others, they didn't understand that an additional day (intercalary day) had to be added every four years. They did it every three years instead! A quarter multiplied by four makes one - what could be simpler? Of course, you get one by muliplying a quarter by three! I still don't see how they could have been so dumb. Enter Augustus Caesar. He corrected the system and intercalary days were omitted between 8 B.C. and 4 A.D. so 5 A.D. is the first correct Julian date. Augustus also was responsible for giving the months their modern number of days. The month July is the Roman month Julius named after Julius Caesar and the month August is named after Augustus. Augustus decided that no month would have more days than his month which is why it has 31 days. -------------------------- Constantine I (The Great) ? 280 - 337 A.D. -------------------------- In ancient times there weren't weeks, although there were natural time periods. Look at the dreadful ancient Roman system! Emperor Constantine I was responsible for the official introduction of the modern seven day week. He was proclaimed Emperor at York in 306 A.D. so the date was somewhere between 306 and 337 A.D. Maybe someone has it more accurately... --------------------- The Days of the Week --------------------- The days of the week did have names prior to Constantine and an unofficial seven day week appears to have existed in the ancient Roman world by about the 1st century B.C. The seven most important "planets" in their order of importance in ancient times were: Saturn Jupiter Mars Sun Venus Mercury Moon I do know that these aren't now accepted literally as all planets! These seven planets were understood to govern in turn each successive hour of the 24 hour day: Hour Planet 1st Day 1 Saturn Saturn's Day 2 Jupiter 3 Mars 4 Sun 5 Venus 6 Mercury 7 Moon 8 Saturn 9 Jupiter 10 Mars 11 Sun 12 Venus 13 Mercury 14 Moon 15 Saturn 16 Jupiter 17 Mars 18 Sun 19 Venus 20 Mercury 21 Moon 22 Saturn 23 Jupiter 24 Mars 2nd Day 1 Sun Sun's Day 2 Venus 3 Mercury 4 Moon etc. The first day begins with Saturn, the second with Sun etc. The order for the days has been the same ever since, namely: Saturn Sun Moon Mars Mercury Jupiter Venus Saturday = Saturn's day Sunday = Sun's day Monday = Moon's day Tuesday = Tiw's day (Mars day) The Saxon God Tiw = Tuisto = Tuesco is identified with the ancient Norse God Tyr. Tyr was responsible treaties oaths and justice. Tyr wanted to trap Fenrir (The Wolf) and placed his hand in Fenrir's mouth as a sign of his good faith while pretending to have a bit of fun. However he tied Fenrir up. In retaliation Fenrir bit off Tyr's hand. The Romans identified Tyr with Mars. Another God was also identified with Mars by the Romans, namely Teutates. Teutates was the God of the People. Sacrifices were allegedly made to him by plunging the unfortunate honoured idiot head first into a vat of ale. What a way to go! Pity it has nothing to do with Tuesday... Wednesday = Woden's day (Mercury's day) (Odin = Woden = Wodan = Wotan) Woden is the older form of Odin, another Norse God, and he was identified with Mercury by the Romans. From earliest times Woden was a God of War. Fallen warriors joined him in Valhalla. He rode an eight legged horse called Sleipnir. He is often shown as a old man with a beard and only one eye. He exchanged his other eye for wisdom. Thursday = Thor's day (Jupiter's day) (Thor = Thunor or Thornar in England) The Romans identified the Norse God Thor with Jupiter. Thor was second only to Odin. He was depicted as a warrior God and Odin was (in some stories) his father. Thor had a magic hammer called Mollnir (or Mjollnir) which returned to the thrower. Thunder was Thor throwing his hammer about. Friday = Frigga's day (Frigga = Frigg = Friia = Frea = Frija and probably a hundred other spellings) Frigga was the mother of Balder and the wife of Odin. She was one very sexy lady! She was also a very loving mother. Balder ("The Shining One", The God of Re-Birth or Renewal) was special. The main story concerns his death. The Gods used to amuse themselves by throwing stones at Balder knowing that he couldn't be hurt. The God Loki (The Trickster, The Forest Fire, identified with Lucifer) tricked the blind God Hod into throwing mistletoe, the only thing that could hurt Balder, and Balder died. This represents the end of the old year and the start of the new. --------------------------- The Great Paschal Calendar 463 A.D --------------------------- Does anyone actually inderstand this? This was intended to be a way of combining the Lunar (? Metonic 19 year) and Solar(28 year) cycles. This was only used by academics such as the Venerable Bede (approx 673-735). The word "style" for a type of calendar appeared somewhere about the 6th century. ------------ Middle Ages ------------ Up to about the 14th century, the new year started on 25th December. This is the year's renewal and the Christians took the already existing feast day for their own. After the 14th century the new year started on 25th March! Now what year was 26th December 1151? In modern language is it 1152? There is something strange here! I confess to being confused. ------------------ Pope Gregory XIII ------------------ As already indicated, Sosigenes didn't quite get the length of the year correct when advising Julius Caesar. He over-estimated by approximately 11 minutes and 14 seconds. Not much in a year, but a long time when accumulated over centuries. In the 1500s it became obvious that the date was out of line with the natural year. Pope Gregory got the Jesuit astronomer Christopher Clavius to draw up a papal bull. Clavius used suggestions from the astronomer and physician Luigi (Aloyisius) Lilio, and the bull appeared in 1582. This decreed that the day after 5th October 1582 (Feast of St. Francis) would be 15th October 1582. This would bring back the vernal (Spring) equinox back to 21st March. Also, from then on, no century year would be a leap year unless it was divisible by 400 e.g. 1900 would not be a leap year but the year 2000 would be a leap year. This is the modern Gregorian calendar. Unfortunately by the time Gregory issued the bull a great number of countries had split with the Roman Catholic Church so it did not become universal. The Julian calendar (Old Style or O.S.) continued in most Protestant countries but very quickly most R.C. countries accepted the Gregorian calendar (New Style or N.S.). So, 15th October 1582 is the first legal Gregorian calendar date. ---------------------------- Dates of changeover to N.S. ---------------------------- 1582 France, Spain, Portugal, Italy, Luxembourg (immediate) 1584 Most other R.C. countries 1587 Hungary 1699-1700 Denmark, Protestant Dutch and German states 1752 Britain and British Empire 1753 Sweden (but didn't use the calendar rules till 1844) 1867 Alaska (bought by U.S. from Russia) 1873 Japan 1875 Egypt 1912-1917 China, Turkey, Albania, Baltic states, Balkan states 1918 Russia 1923 Greece The British change to the New Style was in 1752 when 2nd September 1752 was followed by 14th September 1752. There was public rioting in the streets as people demanded the return of their missing 11 days! As far as I can ascertain there is no country now using the Old Style Julian calendar. Calculation =========== Basically there is only one method of calculating which day of the week was a particular date and that is to count up all the days from zero and divide by seven. The remainder (modulo 7 in this case) represents the day's number. Use this to read the day from an array of the seven days of the week. There are 365 days in a normal year which means the days advance by 1 every year. In a leap year an extra day has to be added. Simply follow the rules for leap years and add to the number of years. --------- Method 1 --------- This is the most simple approach and performs the calculation exactly as above. In fact it is the method I have used in this simple demonstration program. I have simplified it very slightly by counting the 4 year cycles and multiplying by the number of days in a 4 year cycle and the same with the 400 year cycles in the case of the Gregorian calendar. With the Gregorian calendar there has to be a deduction for century years occurring after the last 400 year cycle because these are not leap years although they are divisible by 4. If you wanted to you could make the program add up all the days of each year up to the present with a loop but that isn't exactly the best way to go about it. --------- Method 2 - Gauss's Method --------- I'm sure all sane programmers would use this approach, so here it is.... C.F. Gauss (1777-1855) was a very brilliant mathemetician. He devised this extremely neat formula for calculating the day of the week: A = int[2.6m - .2] + d + y + int[y/4] + int[c/4] - 2c where c = century (if year is 1992, c = 19) y = year in it's century (if year is 1992, y = 92) m = month (March = 1, April = 2 etc. Jan = 11, Feb = 12) d = day of month BUT if the month is January or February then it is considered to be the 11th or 12th month of the PREVIOUS year so 1 has to be deducted from the year to obtain the correct answer. To obtain the day of the week, use A mod 7 to get a number from 0 to 7. 0 is Sunday, 1 is Monday etc. The crucial part of Gauss's formula is the part which calculates the number of days in this year up to the start of this month. To do this in a single calculation is very clever, namely int[2.6m - .2]. For the C language this could be converted to (26 * m - 2) / 10 using integer maths. The following shows that Gauss got it right. Gauss's formula produces the following results:- Deduct 2 March int[2.6 * 1 - .2] = 2 0 April int[2.6 * 2 - .2] = 5 3 May int[2.6 * 3 - .2] = 7 5 June int[2.6 * 4 - .2] = 10 8 July int[2.6 * 5 - .2] = 12 10 August int[2.6 * 6 - .2] = 15 13 September int[2.6 * 7 - .2] = 18 16 October int[2.6 * 8 - .2] = 20 18 November int[2.6 * 9 - .2] = 23 21 December int[2.6 * 10 - .2] = 25 23 January int[2.6 * 11 - .2] = 28 26 February int[2.6 * 12 - .2] = 31 29 Now calculate the sum of the days (mod 7's of the month) to each month:- Days mod 7 Sum at Month Move down March 31 3 3 0 (Start of year!) April 30 2 5 3 May 31 3 8 5 June 30 2 10 8 July 31 3 13 10 August 31 3 16 13 September 30 2 18 16 October 31 3 21 18 November 30 2 23 21 December 31 3 26 23 January 31 3 29 26 February - - - 29 You should spot the similarity between the two right hand columns! A simple constant of -2 applied to Gauss's formula gives exactly the same result as if it had been worked out manually. Gauss's method has one more neat twist. By putting February last, there is no need to worry about whether the year is a leap year. I don't know how Gauss arrived at his formula but it can't be improved upon! This Program ============ This program is a simple demonstration. Click on its icon and the user is presented with a prompt for the day, month and year. This has to be on or after 5 A.D. Although weeks were officially meaningless before the 3rd century A.D. there were days! This program responds with the weekday of both the Julian calendar (Old Style or O.S.) and the Gregorian calendar (New Style or N.S.). The program makes the assumption that the number of the year increments on the first of January. Note O.S. and N.S. represent different days which happen to have the same date in the two systems. This program does NOT convert from one to the other. Gregorian dates of earlier than 15-10-1582 are illegal, but I have continued Julian dates indefinitely. To exit the program simply enter 0,0,0 and it will terminate. David M. Balean 44, Wyong Road Killarney Vale N.S.W. 2261  ### 30 ### 30 ### 30 ### 30 ### 30 ### 30 ### 30 ### 30 ### 30 ### 30 ###