Changeset 589 for trunk/libIGCM/libIGCM_date
- Timestamp:
- 03/20/12 15:27:33 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_date/libIGCM_date.ksh
r554 r589 944 944 } 945 945 946 #D-#================================================================== 947 #D-function IGCM_date_DaysInCurrentPeriod () 948 #D-* Purpose: Give the numbers of days during the Current prd1 period from grg1 date 949 #D-* Usage: IGCM_date_DaysInCurrentPeriod grg1 prd1 950 #D- where grg1 gregorian date is in the form yyyymmdd 951 #D- where prd1 period is in the form N[Yy], N[Mm], N[Dd]. N integer 952 #D- 953 function IGCM_date_DaysInCurrentPeriod { 954 IGCM_debug_PushStack "IGCM_date_DaysInCurrentPeriod" $@ 955 typeset Length Period 956 Period=${2} 957 case ${Period} in 958 *Y|*y) 959 PeriodLengthInYears=$( echo ${Period} | awk -F '[yY]' '{print $1}' ) 960 IGCM_date_GetYearMonth ${1} year month 961 year=$( IGCM_date_SupressZeros ${year} ) 962 (( Length=0 )) 963 (( i=0 )) 964 until [ $i -ge $PeriodLengthInYears ] ; do 965 (( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) )) 966 (( i=i+1 )) 967 done 968 ;; 969 *M|*m) 970 PeriodLengthInMonths=$( echo ${Period} | awk -F '[mM]' '{print $1}' ) 971 IGCM_date_GetYearMonth ${1} year month 972 year=$( IGCM_date_SupressZeros ${year} ) 973 (( year0 = year )) 974 (( Length=0 )) 975 (( i=0 )) 976 until [ $i -ge $PeriodLengthInMonths ] ; do 977 if [ $(( month + i )) -lt 13 ] ; then 978 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 979 else 980 (( year = year0 + 1 )) 981 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 982 fi 983 (( i=i+1 )) 984 done 985 ;; 986 *D|*d) 987 Length=$( echo ${Period} | sed -e "s/[dD]//" ) ;; 988 *) 989 IGCM_debug_Exit "IGCM_date_DaysInCurrentPeriod " ${Period} " invalid PeriodLength : choose in *Y, *M, *D." 990 IGCM_debug_Verif_Exit_Post ;; 991 esac 992 echo ${Length} 993 994 IGCM_debug_PopStack "IGCM_date_DaysInCurrentPeriod" 995 } 946 996 947 997 #D-#==================================================================
Note: See TracChangeset
for help on using the changeset viewer.