'Convert a Julian day number to a Gregorian date (matching
jQuery calendars algorithm)
@param jd: the Julian day number
@return: tuple (year, month, day)'

@staticmethod
def _jd_to_gregorian(jd):

    z = math.floor((jd + 0.5))
    a = math.floor(((z - 1867216.25) / 36524.25))
    a = (((z + 1) + a) - math.floor((a / 4)))
    b = (a + 1524)
    c = math.floor(((b - 122.1) / 365.25))
    d = math.floor((365.25 * c))
    e = math.floor(((b - d) / 30.6001))
    day = ((b - d) - math.floor((e * 30.6001)))
    if (e > 13.5):
        month = (e - 13)
    else:
        month = (e - 1)
    if (month > 2.5):
        year = (c - 4716)
    else:
        year = (c - 4715)
    if (year <= 0):
        year = (year - 1)
    return (int(year), int(month), int(day))
