source: trunk/SRC/Calendar/date2jul.pro @ 210

Last change on this file since 210 was 205, checked in by smasson, 18 years ago

improve the use of high frequency calendar

  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7; gives Julian day equivalent of a date in yyyymmdd format
8;
9; @categories
10; Calendar
11;
12; @param date {in}{required}
13; date in yyyymmdd format
14;
15; @keyword GRADS
16; if  1 <= year <= 49 --> year = 2000 + year
17; if 50 <= year <= 99 --> year = 1900 + year
18;
19; @returns
20; date in Julian day
21;
22; @examples
23;
24; IDL> jday = juldate(19930124)
25; IDL> print, date2jul(19931205) EQ julday(12,5,1993)
26;       1
27; IDL> print, date2jul(931205,/grads) EQ julday(12,5,1993)
28;       1
29;
30; @history
31; Sebastien Masson (smasson\@lodyc.jussieu.fr) June 2005
32;
33; @version $Id$
34;
35;-
36;------------------------------------------------------------
37;------------------------------------------------------------
38;------------------------------------------------------------
39function date2jul, date, GRADS = grads
40;------------------------------------------------------------
41;
42  compile_opt idl2, strictarrsubs
43;
44   year = long(date) / 10000
45   month = long(abs(date)/100) MOD 100
46   day = long(abs(date)) MOD 100
47;------------------------------------------------------------
48   if keyword_set(grads) then year = year $
49     + 1900 * (year GE 50 AND year LE 99) $
50     + 2000 * (year GE  1 AND year LE 49)
51;------------------------------------------------------------
52  IF array_equal(date, long(date)) THEN return, julday(month, day, year)
53 
54  fraction = date - long(date)
55  hour = floor(fraction * 24d)
56  fraction = TEMPORARY(fraction) - hour/24d
57  minute = floor(fraction*1440d)
58  second = (TEMPORARY(fraction) - minute/1440d) * 86400d
59 
60  return, julday(month, day, year, hour, minute, second)
61
62end
63
Note: See TracBrowser for help on using the repository browser.