The GREG2JUL function calculates the Julian Date (which begins at noon) for the specified Gregorian date. This is the inverse of the JUL2GREG procedure.
- The GREG2JUL function uses the proleptic Gregorian date, which is produced by extending the Gregorian calendar backwards to dates preceeding its introduction in 1582. In the proleptic Gregorian calendar, there are no missing days in October 1582, every 4 years is a leap year, except if the year ends in a "00" then it is not a leap year, unless it is also divisible by 400 (in which case it is a leap year).
- There is no year 0 in the calendar as defined by IDL. Instead, year 1 CE is immediately preceded by year 1 BCE. This means that leap years are offset by 1. For example, -1, -5, -9, -13, etc. are all leap years, -101 is not a leap year (following the rule for "00" years), but -401 is a leap year.
- The proleptic Gregorian calendar is usually required for information exchange between international partners, as defined by ISO 8601:2004 (clause 3.2.1). The proleptic Gregorian calendar is not used by astronomers, who instead use the Julian Date, as given by the JULDAY function.
- The GREG2JUL function should only be used with the JUL2GREG procedure. Similarly, the JULDAY function should only be used with CALDAT. For dates between 1 Jan CE and 15 Oct 1582 the two calendar systems differ by up to 10 days. For dates on or after 15 Oct 1582 the two calendar systems are identical.
- A small offset is added to the returned Julian date to eliminate roundoff errors when calculating the day fraction from hours, minutes, seconds. This offset is given by the larger of EPS and EPS*Julian, where Julian is the integer portion of the Julian date, and EPS is the EPS field from MACHAR (using double precision). For typical Julian dates, this offset is approximately 6x10–10 (which corresponds to 5x10–5 seconds). This offset ensures that if the Julian date is converted back to hour, minute, and second, then the hour, minute, and second will have the same integer values as were originally input. For higher precision you should use the MODIFIED keyword.
- Calendar dates must be in the range 24 Oct 4801 BCE to 31 Dec 5000000, which corresponds to Julian values -31776 and 1827933925, respectively.
- This routine is written in the IDL language. Its source code can be found in the file greg2jul.pro in the lib subdirectory of the IDL distribution.
Print out all of the "special" leap days between 1 C.E. and the present:
PRINT, GREG2JUL(2,29,400), GREG2JUL(2,29,800), GREG2JUL(2,29,1200), $
1867216 2013313 2159410 2305507 2451604
Using arrays, this can also be calculated as follows:
As another example, print the number of days between 17 January 1850 and 1 January 850:
PRINT, GREG2JUL(1,17,1850) - GREG2JUL(1,1,850)
Result = GREG2JUL(Month, Day, Year, Hour, Minute, Second [, /MODIFIED])
Result is of type double-precision if Hour, Minute, or Second is specified, otherwise Result is of type long integer. If all arguments are scalars, the function returns a scalar. If all arguments are arrays, the function matches up the corresponding elements of the arrays, returning an array with the same dimensions as the smallest array. If the inputs contain both scalars and arrays, the function uses the scalar value with each element of the arrays, and returns an array with the same dimensions as the smallest input array.
If no arguments are given then the Julian date corresponding to the current system time is returned.
Number of the month (1 = January, ..., 12 = December). Month can be either a scalar or an array.
Number of the day of the month (1-31). Day can be either a scalar or an array.
Number of the year (e.g., 1994). Year can be either a scalar or an array.
Number of the hour of the day (0-23). Hour can be either a scalar or an array.
Number of the minute of the hour (0-59). Minute can be either a scalar or an array.
Number of the second of the minute (0-59). Second can be either a scalar or an array.
Set this keyword to return the Modified Julian Date, which is the regular Julian Date minus 2400000.5. Modified Julian Dates have a precision of approximately 1.2x10–11 (equal to 1x10–6 seconds).
Note: When converting Modified Julian Dates to and from date/times, be sure to specify the MODIFIED keyword on all calls to GREG2JUL and JUL2GREG.
||Added MODIFIED keyword
CALDAT, JUL2GREG, JULDAY, SYSTIME, Date/Time Data