1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; gives yyyymmdd date equivalent of a Julian day |
---|
5 | ; This is the inverse of the function <pro>date2jul</pro>. |
---|
6 | ; |
---|
7 | ; @categories |
---|
8 | ; Calendar |
---|
9 | ; |
---|
10 | ; @param jday {in}{required} {type=long or double, scalar or array} |
---|
11 | ; Julian day |
---|
12 | ; |
---|
13 | ; @keyword MONTH |
---|
14 | ; Set this keyword equal to a named variable that will receive a |
---|
15 | ; longword integer or longword integer array representing the number of |
---|
16 | ; the desired month (1 = January, ..., 12 = December). |
---|
17 | ; |
---|
18 | ; @keyword DAY |
---|
19 | ; Set this keyword equal to a named variable that will receive a |
---|
20 | ; longword integer or longword integer array representing the number of |
---|
21 | ; the day of the month (1-31). |
---|
22 | ; |
---|
23 | ; @keyword YEAR |
---|
24 | ; Set this keyword equal to a named variable that will receive a |
---|
25 | ; longword integer or longword integer array representing the number of |
---|
26 | ; the desired year (e.g., 1994). |
---|
27 | ; |
---|
28 | ; @keyword HOUR |
---|
29 | ; Set this keyword equal to a named variable that will receive a |
---|
30 | ; longword integer or longword integer array representing the number of |
---|
31 | ; the hour of the day (0-23). |
---|
32 | ; |
---|
33 | ; @keyword MINUTE |
---|
34 | ; Set this keyword equal to a named variable that will receive a |
---|
35 | ; longword integer or longword integer array representing the number of |
---|
36 | ; the minute of the hour (0-59). |
---|
37 | ; |
---|
38 | ; @keyword SECOND |
---|
39 | ; Set this keyword equal to a named variable that will receive a |
---|
40 | ; double-precision floating-point value or a double-precision |
---|
41 | ; floating-point array representing the number of the second of the |
---|
42 | ; minute (0-59). |
---|
43 | ; |
---|
44 | ; @returns |
---|
45 | ; the date: longword integer with yyyymmdd format or double-precision |
---|
46 | ; floating-point with yyyymmdd.xx where xx is the fraction of the day |
---|
47 | ; (xx=0 at 0am and 5 at 12am) |
---|
48 | ; |
---|
49 | ; @restrictions |
---|
50 | ; Input param must be longword integer or double-precision floating-point |
---|
51 | ; |
---|
52 | ; @examples |
---|
53 | ; |
---|
54 | ; IDL> print, jul2date(julday(12,23,1999)) |
---|
55 | ; 19991223 |
---|
56 | ; IDL> print, jul2date(julday(12,23,1999,12,0,0)) |
---|
57 | ; 19991224. |
---|
58 | ; IDL> print, jul2date(julday(12,23,1999,12,0,0)), format='(f11.2)' |
---|
59 | ; 19991223.50 |
---|
60 | ; IDL> print, jul2date(julday(12,23,1999,0,0,0)), format='(f11.2)' |
---|
61 | ; 19991223.00 |
---|
62 | ; |
---|
63 | ; @history |
---|
64 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
65 | ; June 2005 |
---|
66 | ; |
---|
67 | ; @version |
---|
68 | ; $Id$ |
---|
69 | ; |
---|
70 | ;- |
---|
71 | function jul2date, jday, MONTH=month, DAY=day, YEAR=year $ |
---|
72 | , HOUR=hour, MINUTE=minute, SECOND=second |
---|
73 | ; |
---|
74 | compile_opt idl2, strictarrsubs |
---|
75 | ; |
---|
76 | sztype = size(jday, /type) |
---|
77 | IF sztype NE 3 AND sztype NE 5 AND sztype LT 13 THEN BEGIN |
---|
78 | dummy = report('Beware of input type, julian date must be long or double') |
---|
79 | stop |
---|
80 | ENDIF |
---|
81 | ; |
---|
82 | caldat, jday, month, day, year, hour, minute, second |
---|
83 | ; |
---|
84 | res = (10000L*year + 100L*month + day)*(year GE 0) $ |
---|
85 | +( 10000L*year - 100L*month - day)*(year LT 0) |
---|
86 | ; |
---|
87 | IF sztype NE 5 THEN return, long(res) $ |
---|
88 | ELSE return, double(res) + (hour / 24.0d0) + (minute/1440.0d0) + (second / 86400.0d0) |
---|
89 | |
---|
90 | end |
---|