Problems with date calculation

Hello all. I'm writing a script that should work with some files being sure that them were created a concrete day (0, 1, 2 or 3 days before script execution). This task should be done under Solaris and Linux hosts with different versions (Solaris 8, 9 and 10, Suse 9 and 10) so I'm trying to make the script as generic as possible, trying to cover the whole system. To calculate the dates I'm doing the following:

    counter=0
    while [ $counter -le 3 ]
    do    
        PreCommand=`expr "$counter" \* 24`
        Day[$counter]=`TZ="$TimeZone"+"$PreCommand"  date +"%d"`
        DayOfWeek[$counter]=`TZ="$TimeZone"+"$PreCommand"  date +"%a"`
        MonthNumber[$counter]=`TZ="$TimeZone"+"$PreCommand"  date +"%m"`
        MonthName[$counter]=`TZ="$TimeZone"+"$PreCommand"  date +"%b"`
        YearLong[$counter]=`TZ="$TimeZone"+"$PreCommand"  date +"%Y"`
        YearShort[$counter]=`TZ="$TimeZone"+"$PreCommand"  date +"%y"`
        
        counter=`expr "$counter" + 1`
    done

I've tested it in some machines and works perfectly, so in a Suse 9 an offset over 24h to TZ is ignored, so the result for today (28) is:

Day[0]=28
Day[1]=27
Day[2]=27
Day[3]=27

Does someone know why it happen, how to solve it or an alternative way valid under Linux and Solaris?

Thank you very much in advance

PS: the scripting language is ksh

Maybe this link can bring you some lightness in the dark:

http://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html

Regards

The date scripts in The Dating Game will work in any POSIX shell.

Perhaps you could use something like this:

$> date
Wed Oct 28 21:42:26 CET 2009
$> ls -l testfile
-rw-r--r-- 1 me me 402 2009-10-26 23:37 testfile
file=testfile
for i in {0..3}; do 
  if [ "$file" = "$(find $file -mtime $i 2>&-)" ] ;
    then echo file $file was modified $i days ago
  fi
done
file testfile was modified 1 days ago

Note that the result is 1 day ago since it is not yet 2 days ago in the example.