John:
Here's a julian date solution that I ripped off, er borrowed, from the US Naval Observatory. It works on other dates other than yesterdays:
#!/bin/ksh
# The Julian date (JD) is a continuous count of days from 1 January 4713 BC.
# The following # algorithm is good from years 1801 to 2099
# See URL:
for more information
get_JD ()
{
typeset -i JDD
JDD=$(($1-32075+1461*($3+4800+($2-14)/12)/4+367*($2-2-($2-14)/12*12)/12-3*(($3+4900+($2-14)/12)/100)/4))
echo $JDD
}
# This function computes the gregorian date from the julian date - $1. Returns a
# date strin of the form: MONTH DAY YEAR
# See URL:
for more information
get_greg_from_JD ()
{
typeset -i L
typeset -i N
typeset -i I
typeset -i J
typeset -i DAY
typeset -i MON
typeset -i YR
L=$(($1+68569)) # $1 is the julian date
N=$((4*L/146097))
L=$((L-(146097*N+3)/4))
I=$((4000*(L+1)/1461001))
L=$((L-1461*I/4+31))
J=$((80*L/2447))
DAY=$((L-2447*J/80))
L=$((J/11))
MON=$((J+2-12*L))
YR=$((100*(N-49)+I+L))
echo $MON $DAY $YR
}
TY=$(date '+%Y') # Year for today
TM=$(date '+%m') # Month for today
TD=$(date '+%d') # Day for today
# printf "%s %s %s\n" $TM $TD $TY
JD=$(get_JD TD TM TY) # today's Julian date
# yesterday's date
yesterdays_date_str=$(get_greg_from_JD $((JD-1)) )
# parse yesterdays date string
set - $(echo $yesterdays_date_str)
echo $1 # month
echo $2 # day
echo $3 # year
# end script