;*************************************************** ; This program takes in the year month and day. It ; calculates the day of the year ;*************************************************** pro days_in_month,year,month,numdays ;year=2007 ;month=4 ;****************************** ; Check if the year is a leap year ;****************************** leap_flag=0 ;not a leap year check4=(year) mod 4 ;years divisible by 4 are leap years, unless........... check100=(year) mod 100 ;years also divisible by 100 are not leap years, except....... check400=(year)mod 400 ;years divisible by 400 are leap years. if ( (check4 eq 0 and check100 ne 0) or (check400 eq 0) ) then leap_flag=1 ;leap year ;****************************** ; Make an array of the number of days ;****************************** if leap_flag eq 0 then begin ; J F M A M J J A S O N D num_days=[31,28,31,30,31,30,31,31,30,31,30,31] endif else if leap_flag eq 1 then begin num_days=[31,29,31,30,31,30,31,31,30,31,30,31] endif ; Number of days in the month numdays=num_days[month-1] return end