def from_jd(jd):
wjd = floor(jd - <NUM_LIT:0.5>) + <NUM_LIT:0.5><EOL>depoch = wjd - EPOCH<EOL>quadricent = floor(depoch / INTERCALATION_CYCLE_DAYS)<EOL>dqc = depoch % INTERCALATION_CYCLE_DAYS<EOL>cent = floor(dqc / LEAP_SUPPRESSION_DAYS)<EOL>dcent = dqc % LEAP_SUPPRESSION_DAYS<EOL>quad = floor(dcent / LEAP_CYCLE_DAYS)<EOL>dquad = dcent % LEAP_CYCLE_DAYS<EOL>yindex = floor(dquad / YEAR_DAYS)<EOL>year = (<EOL>quadricent * INTERCALATION_CYCLE_YEARS +<EOL>cent * LEAP_SUPPRESSION_YEARS +<EOL>quad * LEAP_CYCLE_YEARS + yindex<EOL>)<EOL>if not (cent == <NUM_LIT:4> or yindex == <NUM_LIT:4>):<EOL><INDENT>year += <NUM_LIT:1><EOL><DEDENT>yearday = wjd - to_jd(year, <NUM_LIT:1>, <NUM_LIT:1>)<EOL>leap = isleap(year)<EOL>if yearday < <NUM_LIT> + leap:<EOL><INDENT>leap_adj = <NUM_LIT:0><EOL><DEDENT>elif leap:<EOL><INDENT>leap_adj = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>leap_adj = <NUM_LIT:2><EOL><DEDENT>month = floor((((yearday + leap_adj) * <NUM_LIT:12>) + <NUM_LIT>) / <NUM_LIT>)<EOL>day = int(wjd - to_jd(year, month, <NUM_LIT:1>)) + <NUM_LIT:1><EOL>return (year, month, day)<EOL>
Return Gregorian date in a (Y, M, D) tuple