I think I can say a bit more about it now. "date +%m" outputs the month in zero-padded form.
But bash treats integers starting with 0 as octal values, so you're ok from 01-07, but 08 and 09 are illegal in all of your arithmetic functions.
A quick glance at the date man page shows that, instead of using sed or other tricks, you can simply use a hyphen in the format string to force it not to zero-pad. e.g. "date +%-m".
Oh, and here's an even cleaner way to re-pad the numbers afterwards, using bash's builtin printf function:
Code:
MONTH=$(printf %02d $MONTH)
YESTERDAY=$(printf %02d $YESTERDAY)
Edit: And one last thing. I was puzzled about your two "set" lines at the beginning of the script, but now I see that they're supposed to be array values. But that's not how to populate an array. You need something like this instead:
Code:
DAYS=( Sat Sun Mon Tue Wed Thu Fri Sat )
MONTHS=( Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec )
After I made all the above changes, your script seems to give me the kind of output I'd expect it to.