My Bash Snippets

interactive date

(the difference part requires "dateutils") but can be removed without loss.
will NOT let you leave until you provide a valid date.
(overall, this is hacky and clunky because it clobbers variables. not a clean function.

function int_date () {
when=""
while [[ $date_confirmed == "no" ]]; do
echo "when?"
read when
date -d "$when" > /dev/null
if [ $? == 0 ]; then
date_confirmed="yes"
outputdate=$(date -d "$when" +"%Y-%m-%d")
outputtime=$(date -d "$when" +"%R")
echo "So: $(date -d "$when" +"%A, %B %e - %r - %x")"
diffdate=$(date -d "$when" +"%Y-%m-%d")
echo "which is in $(dateutils.ddiff now "$diffdate") days"
else
echo "that aint a date"
fi

done
}