;+ ; ; @file_comments ; gives yyyymmdd date equivalent of a Julian day ; This is the inverse of the function date2jul. ; ; @categories ; Calendar ; ; @param jday {in}{required} {type=long or double, scalar or array} ; Julian day ; ; @keyword MONTH ; Set this keyword equal to a named variable that will receive a ; longword integer or longword integer array representing the number of ; the desired month (1 = January, ..., 12 = December). ; ; @keyword DAY ; Set this keyword equal to a named variable that will receive a ; longword integer or longword integer array representing the number of ; the day of the month (1-31). ; ; @keyword YEAR ; Set this keyword equal to a named variable that will receive a ; longword integer or longword integer array representing the number of ; the desired year (e.g., 1994). ; ; @keyword HOUR ; Set this keyword equal to a named variable that will receive a ; longword integer or longword integer array representing the number of ; the hour of the day (0-23). ; ; @keyword MINUTE ; Set this keyword equal to a named variable that will receive a ; longword integer or longword integer array representing the number of ; the minute of the hour (0-59). ; ; @keyword SECOND ; Set this keyword equal to a named variable that will receive a ; double-precision floating-point value or a double-precision ; floating-point array representing the number of the second of the ; minute (0-59). ; ; @returns ; the date: longword integer with yyyymmdd format or double-precision ; floating-point with yyyymmdd.xx where xx is the fraction of the day ; (xx=0 at 0am and 5 at 12am) ; ; @restrictions ; Input param must be longword integer or double-precision floating-point ; ; @examples ; ; IDL> print, jul2date(julday(12,23,1999)) ; 19991223 ; IDL> print, jul2date(julday(12,23,1999,12,0,0)) ; 19991224. ; IDL> print, jul2date(julday(12,23,1999,12,0,0)), format='(f11.2)' ; 19991223.50 ; IDL> print, jul2date(julday(12,23,1999,0,0,0)), format='(f11.2)' ; 19991223.00 ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; June 2005 ; ; @version ; $Id$ ; ;- function jul2date, jday, MONTH=month, DAY=day, YEAR=year $ , HOUR=hour, MINUTE=minute, SECOND=second ; compile_opt idl2, strictarrsubs ; sztype = size(jday, /type) IF sztype NE 3 AND sztype NE 5 AND sztype LT 13 THEN BEGIN dummy = report('Beware of input type, julian date must be long or double') stop ENDIF ; caldat, jday, month, day, year, hour, minute, second ; res = (10000L*year + 100L*month + day)*(year GE 0) $ +( 10000L*year - 100L*month - day)*(year LT 0) ; IF sztype NE 5 THEN return, long(res) $ ELSE return, double(res) + (hour / 24.0d0) + (minute/1440.0d0) + (second / 86400.0d0) end