def delta(text):
    '''
    Parse a simple time delta string and return the delta.
    '''
    text = text.strip().lower()

    _, offs = _noms(text, 0, ' \t\r\n')

    sign = '+'
    if text and text[0] in ('+', '-'):
        sign = text[0]
        offs += 1

    _, offs = _noms(text, offs, ' \t\r\n')

    sizetext, offs = _noms(text, offs, '0123456789')

    _, offs = _noms(text, offs, ' \t\r\n')

    unittext = text[offs:]

    size = int(sizetext, 0)

    if sign == '-':
        size = -size

    base = timeunits.get(unittext)
    if base is None:
        mesg = f'unknown time delta units: {unittext}'
        raise s_exc.BadTypeValu(name='time', valu=text, mesg=mesg)

    return size * base
def delta ( text ) : text = text . strip ( ) . lower ( ) _ , offs = _noms ( text , 0 , ' \t\r\n' ) sign = '+' if text and text [ 0 ] in ( '+' , '-' ) : sign = text [ 0 ] offs += 1 _ , offs = _noms ( text , offs , ' \t\r\n' ) sizetext , offs = _noms ( text , offs , '0123456789' ) _ , offs = _noms ( text , offs , ' \t\r\n' ) unittext = text [ offs : ] size = int ( sizetext , 0 ) if sign == '-' : size = - size base = timeunits . get ( unittext ) if base is None : mesg = f'unknown time delta units: {unittext}' raise s_exc . BadTypeValu ( name = 'time' , valu = text , mesg = mesg ) return size * base
Parse a simple time delta string and return the delta.