def floor(start, resolution):
if resolution == STEP_10_SEC:<EOL><INDENT>return datetime(start.year, start.month, start.day, start.hour,<EOL>start.minute, start.second - (start.second % <NUM_LIT:10>))<EOL><DEDENT>elif resolution == STEP_1_MIN:<EOL><INDENT>return datetime(start.year, start.month, start.day, start.hour,<EOL>start.minute)<EOL><DEDENT>elif resolution == STEP_5_MIN:<EOL><INDENT>return datetime(start.year, start.month, start.day, start.hour,<EOL>start.minute - (start.minute % <NUM_LIT:5>))<EOL><DEDENT>elif resolution == STEP_1_HOUR:<EOL><INDENT>return datetime(start.year, start.month, start.day, start.hour)<EOL><DEDENT>elif resolution == STEP_1_DAY:<EOL><INDENT>return datetime(start.year, start.month, start.day)<EOL><DEDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>".format(resolution=resolution,<EOL>choices=STEP_CHOICES))<EOL>
Floor a datetime by a resolution.

    >>> now = datetime(2012, 7, 6, 20, 33, 16, 573225)
    >>> floor(now, STEP_1_HOUR)
    datetime.datetime(2012, 7, 6, 20, 0)