def from_jd(jd):
jd = trunc(jd) + <NUM_LIT:0.5><EOL>depoch = jd - to_jd(<NUM_LIT>, <NUM_LIT:1>, <NUM_LIT:1>)<EOL>cycle = trunc(depoch / <NUM_LIT>)<EOL>cyear = (depoch % <NUM_LIT>)<EOL>if cyear == <NUM_LIT>:<EOL><INDENT>ycycle = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>aux1 = trunc(cyear / <NUM_LIT>)<EOL>aux2 = cyear % <NUM_LIT><EOL>ycycle = trunc(((<NUM_LIT> * aux1) + (<NUM_LIT> * aux2) + <NUM_LIT>) / <NUM_LIT>) + aux1 + <NUM_LIT:1><EOL><DEDENT>year = ycycle + (<NUM_LIT> * cycle) + <NUM_LIT><EOL>if (year <= <NUM_LIT:0>):<EOL><INDENT>year -= <NUM_LIT:1><EOL><DEDENT>yday = (jd - to_jd(year, <NUM_LIT:1>, <NUM_LIT:1>)) + <NUM_LIT:1><EOL>if yday <= <NUM_LIT>:<EOL><INDENT>month = ceil(yday / <NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>month = ceil((yday - <NUM_LIT:6>) / <NUM_LIT:30>)<EOL><DEDENT>day = int(jd - to_jd(year, month, <NUM_LIT:1>)) + <NUM_LIT:1><EOL>return (year, month, day)<EOL>
Calculate Persian date from Julian day