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