source: trunk/SRC/Calendar/leapyr.pro @ 93

Last change on this file since 93 was 93, checked in by pinsard, 18 years ago

start to modify headers of Calendar and Utilities *.pro files for bet
ter idldoc output

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1;-----------------------------------------------------------------
2;+
3;
4; determine whether the input year is a leap year or not
5; Very useful for finding number of days in a year.
6; eg. NUM_DAYS_IN_YR = 365 + leapyr(year)
7;
8; @categories calendar
9;
10; @param year {in}{required} year to be tested as a leap year
11;
12; @returns 0 then not a leap year
13;          1 then year is a leap year
14;
15; @uses cm_4cal
16;
17; @examples
18; IDL> result = leapyr(2000)
19;
20; @history
21;
22; Originally Written by: Trevor Harris, Physics Dept., University of Adelaide,
23;20/09/88
24;
25;       November 2004: correction for century years... S. Masson;
26;
27;       Every year divisible by 4 is a leap year.
28;       But every year divisible by 100 is NOT a leap year
29;       Unless the year is also divisible by 400, then it is still a
30;       leap year.
31;       This means that year 1800, 1900, 2100, 2200, 2300 and 2500 are
32;       NOT leap years, while year 2000 and 2400 are leap years.
33;       + supress the automatic change 89 -> 1989
34;
35;       June 2005 update for new commons, Sebastien Masson.
36;
37;-
38;------------------------------------------------------------
39function leapyr, year
40; include commons
41@cm_4cal
42  yr = long(year)
43  IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg'
44;
45  IF key_caltype NE 'greg' THEN BEGIN
46    sd = size(yr, /dimensions)
47    IF sd[0] EQ 0 THEN return, 0b ELSE return, bytarr(size(yr, /dimensions))
48  ENDIF ELSE return, (yr MOD 4 EQ 0)*((yr MOD 100 NE 0) + (yr MOD 400 EQ 0))
49
50end
Note: See TracBrowser for help on using the repository browser.