code: func ParseExtendedDuration(s string) (time.Duration, error) {
  	if len(s) == 0 {
  		return 0, errDurationEmpty
  	}
  	var isNegative bool
  	if s[0] == '-' {
  		isNegative = true
  		s = s[1:]
  	}
  
  	var d time.Duration
  	i := 0
  
  	for i < len(s) {
  		if !isDigit(s[i]) {
  			return 0, fmt.Errorf("invalid duration %s, no value specified", s)
  		}
  
  		// Consume [0-9]+
  		n := 0
  		for i < len(s) && isDigit(s[i]) {
  			n *= 10
  			n += int(s[i]) - int('0')
  			i++
  		}
  
  		// Consume [^0-9]+ and convert into a unit
  		if i == len(s) {
  			return 0, fmt.Errorf("invalid duration %s, no unit", s)
  		}
  
  		unitStart := i
  		for i < len(s) && !isDigit(s[i]) {
  			i++
  		}
  
  		unitText := s[unitStart:i]
  		unit, unitExists := durationUnits[unitText]
  		if !unitExists {
  			return 0, fmt.Errorf("invalid duration %s, invalid unit %s", s, unitText)
  		}
  
  		d += time.Duration(n) * unit
  
  	}
  
  	if isNegative {
  		d = -d
  	}
  	return d, nil
  }
docs: // ParseExtendedDuration parses a duration, with the ability to specify time
  // units in days, weeks, months, and years.