;----------------------------------------------------------------- function leapyr, year ;+ ; NAME: leapyr ; ; PURPOSE: 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) ; ; CATEGORY: Utility ; ; CALLING SEQUENCE: result = leapyr(year) ; ; INPUTS: year = test if year is a leap year ; ; OUTPUTS: result = 0 then not a leap year ; = 1 then year is a leap year ; ; COMMON BLOCKS: cm_4cal ; ; SIDE EFFECTS: ; none. ; MODIFICATION 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. ; ;- ;------------------------------------------------------------ ; include commons @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