source: trunk/SRC/Calendar/daysinmonth.pro @ 357

Last change on this file since 357 was 325, checked in by pinsard, 17 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1;+
2;
3; @file_comments
4; give the number of days in a specific month
5;
6; @categories
7; Calendar
8;
9; @param MONTH {in}{optional} {type=integer}
10; month number
11;
12; @param YEAR {in}{optional} {default=from "time" common variable of cm_4cal}
13; To specify the year of the month. Used only if the common variable
14; key_caltype = 'greg'. In that case, month and year must have the same
15; number of elements.
16;
17; @returns
18; number of days in a month or -1 in case of error
19;
20; @uses
21; cm_4cal
22; updatenew
23;
24; @examples
25; IDL> ndays = daysinmonth(2, 2000)
26;
27; @history
28; Sebastien Masson (smasson\@lodyc.jussieu.fr)
29; 2/7/98
30; update/review/english/new commons: June 2005 Sebastien Masson.
31;
32; @version
33; $Id$
34;
35;-
36function daysinmonth, month, year
37;
38  compile_opt idl2, strictarrsubs
39;
40@cm_4cal
41IF NOT keyword_set(key_forgetold) THEN BEGIN
42@updatenew
43ENDIF
44
45  IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg'
46  CASE key_caltype OF
47    '360d': if n_elements(month) GT 1 THEN $
48        return, replicate(30, n_elements(month)) ELSE return, 30
49    'noleap':BEGIN
50      days_in_mth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
51      IF n_elements(month) EQ 0 THEN caldat, time, month
52      return, days_in_mth[month-1]
53    END
54    'greg':BEGIN
55      CASE n_params() OF
56        0:caldat, time, month, day, year
57        2:IF n_elements(month) NE n_elements(year) THEN $
58          return, report('month and year must have the same number of elements')
59        ELSE:return, report('daysinmonth accept 0 or 2 input parameters')
60      ENDCASE
61      days_in_mth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
62      return, days_in_mth[month-1] + leapyr(year)*(month EQ 2)
63    END
64    ELSE:return, report('only 3 types of calendar are accepted: greg, 360d and noleap')
65  ENDCASE
66
67END
Note: See TracBrowser for help on using the repository browser.