def _ord2ymd(n):
<EOL>n -= <NUM_LIT:1><EOL>n400, n = divmod(n, _DI400Y)<EOL>year = n400 * <NUM_LIT> + <NUM_LIT:1>   <EOL>n100, n = divmod(n, _DI100Y)<EOL>n4, n = divmod(n, _DI4Y)<EOL>n1, n = divmod(n, <NUM_LIT>)<EOL>year += n100 * <NUM_LIT:100> + n4 * <NUM_LIT:4> + n1<EOL>if n1 == <NUM_LIT:4> or n100 == <NUM_LIT:4>:<EOL><INDENT>assert n == <NUM_LIT:0><EOL>return year-<NUM_LIT:1>, <NUM_LIT:12>, <NUM_LIT><EOL><DEDENT>leapyear = n1 == <NUM_LIT:3> and (n4 != <NUM_LIT> or n100 == <NUM_LIT:3>)<EOL>assert leapyear == _is_leap(year)<EOL>month = (n + <NUM_LIT:50>) >> <NUM_LIT:5><EOL>preceding = _DAYS_BEFORE_MONTH[month] + (month > <NUM_LIT:2> and leapyear)<EOL>if preceding > n:  <EOL><INDENT>month -= <NUM_LIT:1><EOL>preceding -= _DAYS_IN_MONTH[month] + (month == <NUM_LIT:2> and leapyear)<EOL><DEDENT>n -= preceding<EOL>assert <NUM_LIT:0> <= n < _days_in_month(year, month)<EOL>return year, month, n+<NUM_LIT:1><EOL>
ordinal -> (year, month, day), considering 01-Jan-0001 as day 1.