用户名: 密码: 忘记密码? 注册

zeller.py

作者:  时间: 2010-09-02

#Reesun Huang
#zeller
#algorithms:zeller.algorithms
#2010.09.02

def zeller(month, day, year):
    #define the value of month
    value_month = {'Mar':1, 'Apr':2, 'May':3, 'Jun':4, 'Jul':5, 'Aug':6, \
                   'Sep':7, 'Oct':8, 'Nov':9, 'Dec':10, 'Jan':11, 'Feb':12}
    str_R = {0:'Sun', 1:'Mon', 2:'Tue', 3:'Wed',\
             4:'Thu', 5:'Fri', 6:'Sat'}
    
    century = int(year) / 100
    year = int(year) % 100
    W = (13*value_month[month] - 1) / 5
    X = year / 4
    Y = century / 4
    Z = W + X + Y + int(day) + year - 2*century
    R = Z % 7
    print str_R[R]
    
    return