Convert a Julian Day Number to a Civil Date.
jd is the Julian Day Number.
sg specifies the Day of Calendar Reform.
Returns the corresponding [year, month, day_of_month] as a three-element
array.
# File lib/date.rb, line 418
def self.jd_to_civil(jd, sg=GREGORIAN)
if julian?(jd, sg)
a = jd
else
x = ((jd - 1867216.25) / 36524.25).floor
a = jd + 1 + x - (x / 4.0).floor
end
b = a + 1524
c = ((b - 122.1) / 365.25).floor
d = (365.25 * c).floor
e = ((b - d) / 30.6001).floor
dom = b - d - (30.6001 * e).floor
if e <= 13
m = e - 1
y = c - 4716
else
m = e - 13
y = c - 4715
end
return y, m, dom
end