Xref: utzoo comp.lang.c:18927 comp.sources.wanted:7533 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!husc6!rutgers!att!occrsh!rjd From: rjd@occrsh.ATT.COM (Randy_Davis) Newsgroups: comp.lang.c,comp.sources.wanted Subject: Re: Day of week routine Summary: Not C, but shell, and still useful... Keywords: Does anybody have this? Message-ID: <716@occrsh.ATT.COM> Date: 24 May 89 14:46:49 GMT References: <234@zeek.UUCP> Reply-To: rjd@occrsh.UUCP (Randy_Davis) Followup-To: comp.lang.c Distribution: usa Organization: AT&T Network & Data Systems, OKC Lines: 44 In article <234@zeek.UUCP> larry@zeek.UUCP (Larry Podmolik) writes: |I need a C function that, given a date, would return what day of the |week it fell on. Of course, I didn't think to save it at the time. Well, this is not C, but it is a cheap and easy shell script that will do the same, based on the "cal" command. Randy Davis UUCP: ...(att!)ocrjd!randy ...(att!)occrsh!rjd --------------------------cut here-------------------------------------- # How this for simple - "dow", a simple day of week calculator, written 1/11/89 # by Randy Davis. Error checking and error messages added 3/9/89. USAGE="Usage: $0 month[1-12] day[1-31] year[00-99] - to calculate the day\nof week for a certain date." MONTH=$1 DAY=$2 YR=$3 case "$DAY" in [1-9]|[12][0-9]|3[01]) ;; *) echo $USAGE ; exit ;; esac case "$MONTH" in [1-9]|1[012]) ;; *) echo $USAGE ; exit ;; esac case "$YR" in [0-9][0-9]) ;; *) echo $USAGE ; exit ;; esac set `cal $MONTH 19$YR | egrep "^$DAY | $DAY | $DAY$"` for DOW in Sunday Monday Tuesday Wednesday Thursday Friday Saturday do if [ "$1" = "$DAY" ] then break fi shift done echo $DOW