In this description:
INT(x) = [x] NOTE: some computer languages have a different definition.
FIX(x) = the number x without its fraction. For example, FIX(-1.5)=-1
x\y = FIX(x/y)
STEP 1 Let RD be the Rata Day Number. Calculate
STEP 2 Calculate the value of A which is the number of full centuries:
where 0.002929687499688476 < K1 < 0.2521972656249999
STEP 3 Calculate the days within the whole centuries (in the Julian Calendar) by adding back days removed in the Gregorian Calendar. The value of B is this number of days minus a constant.
where 0 < K2 < 0.25
(It is sometimes convenient to make K1 = K2 = 0.25.)
STEP 4 Calculate the value of Y, the year in a calendar whose years start on March 1:
STEP 5 Calculate the value of the day count in the current year using ONE of the following:
C = B - INT(365.25*Y)
where C is an integer and B is a real.
STEP 6 Calculate the value of the month in the current year using ONE of the following:
(Note that 16384 is 2^14 and the division can be implemented with shifts if the number has a binary representation.)
(Note that 65536 is 2^16 and the can be implemented by taking the upper 16 bits of a 32 bit number.)
where K3 = .0326530612244898 to 0.03271028037383177
STEP 7 Calculate the value of F, which is the number of days in the preceding months in the current year, using ONE of the following methods:
STEP 8 The Gregorian date's day of the month is
STEP 9 Convert the month and year to a calendar starting January 1, using ONE of the following methods:
The Gregorian date has
Year = Y
Month = M
This calculation is valid for any Rata Die number including negative Rata Die numbers and produces a Gregorian date (or possibly a proleptic Gregorian date).
Example
The following sequence calculates Gregorian year Y, month M, and day D from a Rata Die number:
| Z = RD + 306 | step 1 |
| G = Z - .25 | used in later steps |
| A = INT(G / 36524.25) | step 2 |
| B = A - INT(A / 4) | part of step 3 |
| year = INT((B+G) / 365.25) | part of step 3 and step 4 |
| C = B + Z - INT(365.25 * year) | step 5 |
| month = FIX((5 * C + 456) / 153) | step 6 |
| day = C - FIX((153 * month - 457) / 5) | step 7 and 8 |
| IF month > 12 THEN | step 9 |
| year = year + 1 | step 9 |
| month = month - 12 | step 9 |
| END IF | step 9 |