code: func ExtractDurationNum(d *Duration, unit string) (int64, error) {
  	switch strings.ToUpper(unit) {
  	case "MICROSECOND":
  		return int64(d.MicroSecond()), nil
  	case "SECOND":
  		return int64(d.Second()), nil
  	case "MINUTE":
  		return int64(d.Minute()), nil
  	case "HOUR":
  		return int64(d.Hour()), nil
  	case "SECOND_MICROSECOND":
  		return int64(d.Second())*1000000 + int64(d.MicroSecond()), nil
  	case "MINUTE_MICROSECOND":
  		return int64(d.Minute())*100000000 + int64(d.Second())*1000000 + int64(d.MicroSecond()), nil
  	case "MINUTE_SECOND":
  		return int64(d.Minute()*100 + d.Second()), nil
  	case "HOUR_MICROSECOND":
  		return int64(d.Hour())*10000000000 + int64(d.Minute())*100000000 + int64(d.Second())*1000000 + int64(d.MicroSecond()), nil
  	case "HOUR_SECOND":
  		return int64(d.Hour())*10000 + int64(d.Minute())*100 + int64(d.Second()), nil
  	case "HOUR_MINUTE":
  		return int64(d.Hour())*100 + int64(d.Minute()), nil
  	default:
  		return 0, errors.Errorf("invalid unit %s", unit)
  	}
  }
docs: // ExtractDurationNum extracts duration value number from duration unit and format.