def duration(first, last):
    """Evaluate duration

    Parameters
    ----------
    first : int
        First timestamp
    last : int
        Last timestamp

    Returns
    -------
    str
        Formatted string
    """

    ret = ''
    diff = last - first
    if diff <= 0:
        return ''

    mm = divmod(diff, 60)[0]
    if mm == 0:
        # don't bother unless we have some minutes
        return ''

    hh, mm = divmod(mm, 60)
    if hh > 24:
        dd, hh = divmod(hh, 24)
        ret = "%2dd %02dh" % (dd, hh)
    elif hh > 0:
        ret = "%2dh %02dm" % (hh, mm)
    else:
        ret = "%02dm" % (mm)

    return ret