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

Last change on this file since 163 was 157, checked in by navarro, 18 years ago

header improvements + xxx doc

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