Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
- def schwerdtfegers_method(year, month, day):
- """
- Implementation of Schwerdtfeger's_method
- of Julian calendar.
- Look here:
- https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Schwerdtfeger's_method
- """
- if year < 0:
- raise ValueError('Year must be a positive integer')
- if not 1 <= month <= 12:
- raise ValueError('Month must between 1 and 12')
- if not 1 <= day <= 31:
- raise ValueError('Day must between 1 and 31')
- m_table = [None, 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]
- if month >= 3:
- c = year // 100
- g = year - 100 * c
- else:
- c = (year - 1) // 100
- g = year - 1 - 100 * c
- f = c % 7
- w = (day + m_table[month] + f + g + ( g // 4)) % 7
- return w
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement