from ksh93 do

        builtin date

and then use the mutiple date-operand feature to set the date
that "final last month" operates on to capture the problem

        date -f%Y-%m-%d '2011-01-01' 'final last month'
        date -f%Y-%m-%d '2011-01-01' 'final last month'

---
# this script that tests "$final_last" for all days from 2007 through 2011
# this will capture a leap year
# with debug=0 you should get no output
builtin date
typeset -Z2 mm dd
debug=0
final_last='final last month'
final_this='final day'
for ((yyyy = 2007; yyyy <= 2011; yyyy++))
do      for ((mm = 1; mm <= 12; mm++))
        do      dd=1
                exp=$(date -f%Y-%m-%d $yyyy-$mm-$dd "$final_last")
                exp=${exp#????-??-???}
                DD=$(date -f%Y-%m-%d $yyyy-$mm-$dd "$final_this")
                DD=${DD#????-??-???}
                if      [[ ${DD%-??} != $yyyy-$mm ]]
                then    print -u2 "$yyyy-$mm-$dd '$final_this' failed -- 
expected $yyyy-$mm-??, got $DD"
                else    (( debug )) && print $exp
                        DD=${DD#????-??-}
                        for ((dd = 2; dd <= DD; dd++))
                        do      got=$(date -f%Y-%m-%d $yyyy-$mm-$dd 
"$final_last")
                                got=${got#????-??-???}
                                (( debug )) && print $got
                                if      [[ $exp != $got ]]
                                then    print -u2 "$yyyy-$mm-$dd '$final_last' 
failed -- expected $$exp, got $got"
                                fi
                        done
                fi
        done
done
---

On Wed, 12 Jan 2011 08:21:07 -0600 [email protected] wrote:
> We have been using the

> printf "%(%Y-%m-%d)T\n" "final last month"

> with no problems to find the last day of the prior month with no 
> problems for quite some time. This January we discovered that it returns 
> 11/30/10, not 12/31/10.

> It may be that the problem has been a January issue all along and just 
> was not noticed by us or anybody else. It may also be a new issues.

> Has anybody else discovered this issue?

> Tom Lamm
> Marcal Systems
> _______________________________________________
> ast-developers mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-developers

_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to