def template_localtime(value, use_tz=None):
    should_convert = (isinstance(value, datetime)
        and (settings.USE_TZ if use_tz is None else use_tz)
        and not is_naive(value)
        and getattr(value, 'convert_to_local_time', True))
    return localtime(value) if should_convert else value


# Utilities
Used by Motor classes to mark functions as coroutines.
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/utils/timezone.py/template_localtime--crossover with--dataset/ETHPy150Open mongodb/motor/motor/metaprogramming.py/motor_coroutine