#!/bin/csh

switch (`uname -s``uname -r`)
case SunOS5*:
	breaksw
# test on alternate OS's before adding them here
default:
	exec echo ${0}: does not run on `uname -s` `uname -r`
endsw

while($#argv)
        switch ("$1")
        case -d:
# This doesn't work for julian date testing....
                set DATE = ( $2 )
                shift; shift
                breaksw
        case -dow:
                set DATE[1] = $2
                shift; shift
                breaksw
        case -v:
                set VERBOSE
                shift
                breaksw
        default:
                set DQ = '"'
                exec echo ${0}: "What do I do with $DQ$1$DQ?"
        endsw
end

set DATE = `date`

switch ($DATE[1])

case Sun:
if ($?VERBOSE) echo "Sunday reminders:"
	breaksw

case Mon:
if ($?VERBOSE) echo "Monday reminders:"
if ($?VERBOSE) echo Today rtoth is in at 9:00am	# fall, 2001
	if ($DATE[3] < 7) then
		echo General unix staff meeting tomorrow
	else if ($DATE[3] > 6 && $DATE[3] < 14) then
		echo Core unix support meeting tomorrow
	else if ($DATE[3] > 20 && $DATE[3] < 28) then
		echo LCSR general staff meeting tomorrow
	endif
	breaksw

case Tue:
if ($?VERBOSE) echo "Tuesday reminders:"
if ($?VERBOSE) echo Today I am in at 9:00am # fall, 2001
	if ($DATE[3] < 8) then
		echo General unix staff meeting today
	else if ($DATE[3] > 7 && $DATE[3] < 15) then
		echo Core unix support meeting today
	else if ($DATE[3] > 21 && $DATE[3] < 29) then
		echo LCSR general staff meeting today
	endif
	breaksw

case Wed:
if ($?VERBOSE) echo "Wednesday reminders:"
if ($?VERBOSE) echo mcgrew is in at 9:00am # fall, 2001
	if ($DATE[3] > 1 && $DATE[3] < 9) then
		echo Biweekly report due Friday
	else if ($DATE[3] > 15 && $DATE[3] < 23) then
		echo Biweekly report due Friday
	endif
	breaksw

case Thu:
if ($?VERBOSE) echo "Thursday reminders:"
if ($?VERBOSE) echo Today dmotto is in at 9:00am # fall, 2001
	if ($DATE[3] > 2 && $DATE[3] < 10) then
		echo Biweekly report due tomorrow
	else if ($DATE[3] > 16 && $DATE[3] < 24) then
		echo Biweekly report due tomorrow
	endif
	breaksw

case Fri:
if ($?VERBOSE) echo "Friday reminders:"
if ($?VERBOSE) echo Today robtuck is in at 9:00am # fall, 2001
	if ($DATE[3] > 3 && $DATE[3] < 11) then
		echo Biweekly report due today
	else if ($DATE[3] > 17 && $DATE[3] < 25) then
		echo Biweekly report due today
	endif
	breaksw

case Sat:
if ($?VERBOSE) echo "Saturday reminders:"
	breaksw
default:
	echo "*** Day of week unrecognized ***"
	echo "        Reminders omitted"
	breaksw
endsw

#set JDX = `~watrous/Sys/jd -y`
@ JDX = $DATE[6] * 365
@ JDX = $JDX + ( ( $DATE[6] - 1 ) / 4 )
@ JDX = $JDX + `date +%j`

@ JDXM = $JDX - (( $JDX / 14 ) * 14 )

switch ( $JDXM )

case 2:
if ($?VERBOSE) echo "First Sunday reminders:"
	breaksw

case 3:
if ($?VERBOSE) echo "First Monday reminders:"
if ($?VERBOSE) echo "Next Friday is *NOT* payday"
breaksw

case 4:
if ($?VERBOSE) echo "First Tuesday reminders:"
if ($?VERBOSE) echo "Next Friday is *NOT* payday"
	breaksw

case 5:
if ($?VERBOSE) echo "First Wednesday reminders:"
if ($?VERBOSE) echo "Next Friday is *NOT* payday"
	breaksw

case 6:
if ($?VERBOSE) echo "First Thursday reminders:"
	echo "Tomorrow is *NOT* payday"
	breaksw

case 7:
if ($?VERBOSE) echo "First Friday reminders:"
	echo "Today is *NOT* payday"
	breaksw

case 8:
if ($?VERBOSE) echo "First Saturday reminders:"
	breaksw

case 9:
if ($?VERBOSE) echo "Second Sunday reminders:"
	breaksw

case 10:
if ($?VERBOSE) echo "Second Monday reminders:"
if ($?VERBOSE) echo "Next Friday *is* payday"
	breaksw

case 11:
if ($?VERBOSE) echo "Second Tuesday reminders:"
if ($?VERBOSE) echo "Next Friday *is* payday"
	breaksw

case 12:
if ($?VERBOSE) echo "Second Wednesday reminders:"
if ($?VERBOSE) echo "Next Friday *is* payday"
	breaksw

case 13:
if ($?VERBOSE) echo "Second Thursday reminders:"
	echo "Tomorrow *IS* payday"
	breaksw

case 0:
if ($?VERBOSE) echo "Second Friday reminders:"
	echo "Today *IS* payday"
	breaksw

case 1:
if ($?VERBOSE) echo "Second Saturday reminders:"
	breaksw
endsw

# and a "once-a-day" hack

set TMP = /tmp/`basename $0`.`whoami`

if ( -e $TMP) then
    /bin/ls -l $TMP | grep "$DATE[2][ ]*$DATE[3] " > /dev/null
    set FIRST_TIME = $status
else
    set FIRST_TIME = 1
endif
if ($FIRST_TIME) echo This is the first time today you ran $0
touch $TMP

