Converts value from source_unit to target_unit.

    Returns a tuple containing the converted value and target_unit.
    Having fmt set to True causes the value to be formatted to 1 decimal digit
    if it's a decimal or be formatted as integer if it's an integer.

    E.g:

    >>> convert(2, 'hr', 'min')
    (120.0, 'min')
    >>> convert(2, 'hr', 'min', fmt=True)
    (120, 'min')
    >>> convert(30, 'min', 'hr', fmt=True)
    (0.5, 'hr')

def convert(value, source_unit, target_unit, fmt=False):
    """Converts value from source_unit to target_unit.

    Returns a tuple containing the converted value and target_unit.
    Having fmt set to True causes the value to be formatted to 1 decimal digit
    if it's a decimal or be formatted as integer if it's an integer.

    E.g:

    >>> convert(2, 'hr', 'min')
    (120.0, 'min')
    >>> convert(2, 'hr', 'min', fmt=True)
    (120, 'min')
    >>> convert(30, 'min', 'hr', fmt=True)
    (0.5, 'hr')
    """
    orig_target_unit = target_unit
    source_unit = functions.value_for_key(INFORMATION_UNITS, source_unit)
    target_unit = functions.value_for_key(INFORMATION_UNITS, target_unit)

    q = ureg.Quantity(value, source_unit)
    q = q.to(ureg.parse_expression(target_unit))
    value = functions.format_value(q.magnitude) if fmt else q.magnitude
    return value, orig_target_unit