#!/bin/csh
#
# edit with vi an xcal daily diary file, with date defaulting to today.
# From: Scott Brim <swb@chumley.tn.cornell.edu>

# constants
set months = \
{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}

# default to today
set thedate = `date +%m/%d/%y`
if ($1 != "") set thedate = $1

set month =	`echo $thedate | cut -d/ -f1`
set monthname = $months[$month]
set day =	`echo $thedate | cut -d/ -f2`
set year =	`echo $thedate | cut -d/ -f3`
if ( $year < 100 ) @ year = $year + 1900

# build filename
set filename = "~/Calendar/xy"${year}"/xc"${day}${monthname}${year}

if ($?VISUAL) then
	$VISUAL $filename
else
	/usr/ucb/vi $filename
endif

exit $status
