def localtime(value=None, timezone=None):
 if (value is None):
  value = now()
 if (timezone is None):
  timezone = get_current_timezone()
 if is_naive(value):
  raise ValueError('localtime() cannot be applied to a naive datetime')
 value = value.astimezone(timezone)
 if hasattr(timezone, 'normalize'):
  value = timezone.normalize(value)
 return value

def localtime ( value = None , timezone = None ) : if ( value is None ) : value = now ( ) if ( timezone is None ) : timezone = get_current_timezone ( ) if is_naive ( value ) : raise ValueError ( 'localtime() cannot be applied to a naive datetime' ) value = value . astimezone ( timezone ) if hasattr ( timezone , 'normalize' ) : value = timezone . normalize ( value ) return value
converts a datetime to local time in the active time zone .