def clean_year_month(year, month, month_orig):
error = False<EOL>error_msg = "<STR_LIT>"<EOL>if month_orig not in xrange(<NUM_LIT:1>, <NUM_LIT>) and month_orig is not None:<EOL><INDENT>month = now.month<EOL>error = error_msg<EOL><DEDENT>while month > <NUM_LIT:12>:<EOL><INDENT>month -= <NUM_LIT:12><EOL>year += <NUM_LIT:1><EOL><DEDENT>while month < <NUM_LIT:1>:<EOL><INDENT>month += <NUM_LIT:12><EOL>year -= <NUM_LIT:1><EOL><DEDENT>year, month, error = _check_year(year, month, error, error_msg)<EOL>return year, month, error<EOL>
If 'month_orig', which is the month given in the url BEFORE any next/prev
query strings have been applied, is out of range, sets month to the
current month and returns an error message. Also Returns an error
message if the year given is +/- 50 years from now.
If 'month', which is the month given in the url AFTER any next/prev
query strings have been applied, is out of range, adjusts it to be
in range (by also adjusting the year).