;+ ; ; @file_comments ; determine whether the input year is a leap year or not ; Very useful for finding number of days in a year. ; eg. NUM_DAYS_IN_YR = 365 + leapyr(year) ; ; @categories ; Calendar ; ; @param year {in}{required} {type= scalar or array} ; year to be tested as a leap year. ; ; @returns ; 0 then not a leap year, 1 then year is a leap year ; with the same number of elements than year. ; ; @uses ; cm_4cal ; ; @examples ; IDL> result = leapyr(2000) ; ; @history ; ; Originally Written by: Trevor Harris, Physics Dept., University of Adelaide, ;20/09/88 ; ; November 2004: correction for century years... S. Masson; ; ; Every year divisible by 4 is a leap year. ; But every year divisible by 100 is NOT a leap year ; Unless the year is also divisible by 400, then it is still a ; leap year. ; This means that year 1800, 1900, 2100, 2200, 2300 and 2500 are ; NOT leap years, while year 2000 and 2400 are leap years. ; + supress the automatic change 89 -> 1989 ; ; June 2005 update for new commons, Sebastien Masson. ; ; @version ; $Id$ ; ;- ; function leapyr, year ; compile_opt idl2, strictarrsubs ; @cm_4cal yr = long(year) IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' ; IF key_caltype NE 'greg' THEN BEGIN sd = size(yr, /dimensions) IF sd[0] EQ 0 THEN return, 0b ELSE return, bytarr(size(yr, /dimensions)) ENDIF ELSE return, (yr MOD 4 EQ 0)*((yr MOD 100 NE 0) + (yr MOD 400 EQ 0)) end