source: trunk/Calendar/leapyr.pro @ 9

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

upgrade of CALENDRIER/Calendar according to cerbere.lodyc.jussieu.fr:/usr/home/smasson/SAXO_RD/ : files

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