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

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

add $ in Calendar, Grid, Interpolation, Obsolete and Postscript *.pro files, add svn:keywords Id to all these files, some improvements in header

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1;-----------------------------------------------------------------
2;+
3;
4; @file_comments 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; @version $Id$
39;
40;-
41;------------------------------------------------------------
42function leapyr, year
43; include commons
44;
45  compile_opt idl2, strictarrsubs
46;
47@cm_4cal
48  yr = long(year)
49  IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg'
50;
51  IF key_caltype NE 'greg' THEN BEGIN
52    sd = size(yr, /dimensions)
53    IF sd[0] EQ 0 THEN return, 0b ELSE return, bytarr(size(yr, /dimensions))
54  ENDIF ELSE return, (yr MOD 4 EQ 0)*((yr MOD 100 NE 0) + (yr MOD 400 EQ 0))
55
56end
Note: See TracBrowser for help on using the repository browser.