import numbers


def _time2sec(time):
    """Convert string (e.g. 1d or 0.5h) to seconds"""
    if not isinstance(time, numbers.Number):
        time, unit = float(time[:-1]), time[-1]
        assert unit in 'dh'
        time *= 24 * 3600 if unit == 'd' else 3600
    return time