source: trunk/SRC/Calendar/jul2date.pro @ 327

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

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

  • Property svn:keywords set to Id
File size: 2.7 KB
RevLine 
[9]1;+
2;
[126]3; @file_comments
[136]4; gives yyyymmdd date equivalent of a Julian day
[318]5; This is the inverse of the function <pro>date2jul</pro>.
[9]6;
[231]7; @categories
[157]8; Calendar
[9]9;
[318]10; @param jday {in}{required} {type=long or double, scalar or array}
[136]11; Julian day
[9]12;
[279]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;
[231]44; @returns
[279]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)
[9]48;
[279]49; @restrictions
50; Input param must be longword integer or double-precision floating-point
51;
[126]52; @examples
[9]53;
[126]54; IDL> print, jul2date(julday(12,23,1999))
[279]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
[9]62;
[231]63; @history
64; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[9]65;                       June 2005
[118]66;
[231]67; @version
68; $Id$
[118]69;
[9]70;-
[327]71function 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]90end
Note: See TracBrowser for help on using the repository browser.