Compiler helper method: attempt to compile constant into object representing
    datetime or timedelta object to enable relations and thus simple comparisons
    using Python operators.

def compile_timeoper(rule):
    """
    Compiler helper method: attempt to compile constant into object representing
    datetime or timedelta object to enable relations and thus simple comparisons
    using Python operators.
    """
    if isinstance(rule.value, (datetime.datetime, datetime.timedelta)):
        return rule
    if isinstance(rule, NumberRule):
        return compile_timedelta(rule)
    if isinstance(rule, ConstantRule):
        try:
            return compile_datetime(rule)
        except ValueError:
            pass
        try:
            return compile_timedelta(rule)
        except ValueError:
            pass
    raise ValueError("Wrong time operation constant '{}'".format(rule))