Changeset 919
- Timestamp:
- 08/13/13 14:29:16 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_date/libIGCM_date.ksh
r889 r919 838 838 IGCM_debug_PushStack "IGCM_date_DaysInPreviousPeriod" $@ 839 839 840 typeset Length Period PeriodLengthInYears PeriodLengthInMonths year0 i840 typeset Length Period treatedYear PeriodLengthInYears PeriodLengthInMonths year0 i 841 841 842 842 Period=${2} … … 869 869 fi 870 870 month=$( printf "%02i\n" ${month} ) 871 treatedYear=0 871 872 Length=0 872 873 i=0 873 until [ $i -ge $PeriodLengthInMonths ] ; do 874 if [ $(( month + i )) -lt 13 ] ; then 875 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 876 else 874 for ((i = 0; i < ${PeriodLengthInMonths}; i += 1)) ; do 875 876 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 * treatedYear )) ) )) 877 878 if [ $(( month + i )) -ge $(( 12 * (treatedYear + 1) )) ] ; then 877 879 (( year = year0 + 1 )) 878 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) )))880 (( treatedYear = treatedYear + 1 )) 879 881 fi 880 (( i = i + 1 ))881 882 done 882 883 ;; … … 902 903 IGCM_debug_PushStack "IGCM_date_DaysInNextPeriod" $@ 903 904 904 typeset Length Period PeriodLengthInYears PeriodLengthInMonths year0 month0 i905 typeset Length Period treatedYear PeriodLengthInYears PeriodLengthInMonths year0 month0 i 905 906 906 907 Period=${2} … … 928 929 (( year = year0 + 1 )) 929 930 fi 931 treatedYear=0 930 932 Length=0 931 933 i=0 932 until [ $i -ge $PeriodLengthInMonths ] ; do 933 if [ $(( month0 + i )) -lt 13 ] ; then 934 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i )) ) )) 935 else 934 for ((i = 0; i < ${PeriodLengthInMonths}; i += 1)) ; do 935 936 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 * treatedYear )) ) )) 937 938 if [ $(( month0 + i )) -ge $(( 12 * (treatedYear + 1) )) ] ; then 936 939 (( year = year0 + 1 )) 937 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 )) )))940 (( treatedYear = treatedYear + 1 )) 938 941 fi 939 (( i = i + 1 ))940 942 done 941 943 ;; … … 961 963 IGCM_debug_PushStack "IGCM_date_DaysInCurrentPeriod" $@ 962 964 963 typeset Length Period PeriodLengthInYears PeriodLengthInMonths year0 i 965 set -vx 966 967 typeset Length Period treatedYear PeriodLengthInYears PeriodLengthInMonths year0 i 964 968 965 969 Period=${2} … … 987 991 year=$( IGCM_date_SupressZeros ${year} ) 988 992 year0=year 993 treatedYear=0 989 994 Length=0 990 995 i=0 991 until [ $i -ge $PeriodLengthInMonths ] ; do 992 if [ $(( month + i )) -lt 13 ] ; then 993 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 994 else 996 for ((i = 0; i < ${PeriodLengthInMonths}; i += 1)) ; do 997 998 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 * treatedYear )) ) )) 999 1000 if [ $(( month + i )) -ge $(( 12 * (treatedYear + 1) )) ] ; then 995 1001 (( year = year0 + 1 )) 996 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) )))1002 (( treatedYear = treatedYear + 1 )) 997 1003 fi 998 (( i = i + 1 ))999 1004 done 1000 1005 ;; … … 1007 1012 echo ${Length} 1008 1013 1014 set +vx 1015 1009 1016 IGCM_debug_PopStack "IGCM_date_DaysInCurrentPeriod" 1010 1017 }
Note: See TracChangeset
for help on using the changeset viewer.