Created
February 12, 2012 13:54
-
-
Save xream/1808672 to your computer and use it in GitHub Desktop.
zeller week
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
year=2010 | |
mon=01 | |
day=01 | |
case $mon in | |
01) monname="Jan" ;; | |
02) monname="Feb" ;; | |
03) monname="Mar" ;; | |
04) monname="Apr" ;; | |
05) monname="May" ;; | |
06) monname="Jun" ;; | |
07) monname="Jul" ;; | |
08) monname="Aug" ;; | |
09) monname="Sep" ;; | |
10) monname="Oct" ;; | |
11) monname="Nov" ;; | |
12) monname="Dec" ;; | |
esac | |
echo $monname | |
#zeller | |
y=$year | |
m=${mon#0} | |
d=${day#0} | |
if [[ $mon -le 2 ]]; then | |
let m=m+12 | |
let y=y-1 | |
fi | |
c=`echo $y|cut -c -2` | |
c=${c#0} | |
y=`echo $y|cut -c 3-4` | |
y=${y#0} | |
echo $c $y $m $d | |
let m=13*m+13 | |
let w=c/4-2*c+y+y/4+m/5+d-1 | |
let w=w%7 | |
w=${w#-} | |
echo $w | |
case $w in | |
0) w=Sun ;; | |
1) w=Mon ;; | |
2) w=Tue ;; | |
3) w=Wed ;; | |
4) w=Thu ;; | |
5) w=Fri ;; | |
6) w=Sat ;; | |
esac | |
echo $w |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment