The JUL2GREG procedure calculates the Gregorian month, day, year (and optional hour, minute, second) from a Julian Date. This is the inverse of the GREG2JUL function.

Notes

  • The JUL2GREG procedure 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 JUL2GREG procedure should only be used with the GREG2JUL function. 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.
  • Julian values must be between -31776 and 1827933925, which correspond to calendar dates of 24 Oct 4801 BCE and 31 Dec 5000000, respectively.
  • This routine is written in the IDL language. Its source code can be found in the file jul2greg.pro in the lib subdirectory of the IDL distribution.

Examples


Unlike the Julian calendar, in the proleptic Gregorian calendar the year 1500 is not a leap year:

JUL2GREG, 2268982, Month1, Day1, Year1
JUL2GREG, 2268983, Month2, Day2, Year2
PRINT, Month1, Day1, Year1
PRINT, Month2, Day2, Year2

IDL prints:

2    28    1500
3     1    1500

Be sure to distinguish between Month and Minute when assigning variable names. For example, the following code would cause the Month value to be the same as the Minute value:

;Find date corresponding to Julian day 2529161.36:
JUL2GREG, 2492637.36, M, D, Y, H, M, S
PRINT, M, D, Y, H, M, S

IDL prints:

0        4        2112           18            0        0.00000000

Moreover, Julian Dates should be maintained as double-precision floating-point data when the numbers are used to determine hours, minutes, and seconds.

So, instead of the previous call, use a "D" following the number to ensure that it is double precision:

JUL2GREG, 2492637.36D, Month, Day, Year, Hour, Minute, Second
PRINT, Month, Day, Year, Hour, Minute, Second

IDL prints:

7        4        2112           20            38        23.999989

You can also use arrays for the Julian argument:

JUL2GREG, DINDGEN(4) + 2449587.0D, m, d, y
PRINT, m, d, y

IDL prints:

           8           8           8           8
          22          23          24          25
        1994        1994        1994        1994

Syntax


JUL2GREG, Julian, Month [, Day [, Year [, Hour [, Minute [, Second]]]]] [, /MODIFIED]

Arguments


Julian

A numeric value or array that specifies the Julian Date (which begins at noon) to be converted to a calendar date.

Note: Julian Dates should be maintained as double-precision floating-point data when the numbers are used to determine hours, minutes, and seconds.

Month

A named variable that, on output, contains a longword integer or longword integer array representing the number of the month (1 = January, ..., 12 = December).

Day

A named variable that, on output, contains a longword integer or longword integer array representing the number of the day of the month (1-31).

Year

A named variable that, on output, contains a longword integer or longword integer array representing the number of the year (e.g., 1994).

Hour

A named variable that, on output, contains a longword integer or longword integer array representing the number of the hour of the day (0-23).

Minute

A named variable that, on output, contains a longword integer or longword integer array representing the number of the minute of the hour (0-59).

Second

A named variable that, on output, contains a double-precision floating-point value or a double-precision floating-point array representing the number of the second of the minute (0-59).

Keywords


MODIFIED

Set this keyword to treat the input values as Modified Julian Dates (equivalent to the regular Julian Date minus 2400000.5).

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.

Version History


8.2.1

Introduced

8.8.3 Added MODIFIED keyword

See Also


CALDAT, GREG2JUL, JULDAY, SYSTIME, Date/Time Data