// parseDuration parses the scanEvery option into a time
parseDuration parses the scanEvery option into a time
// parseDuration parses the scanEvery option into a time
func parseDuration(scanStr string) (duration time.Duration, err error) {
	r, err := regexp.Compile("(?P<number>[0-9])+\\s*(?P<unit>[s|m|d|M])")
	if err != nil {
		log.Error("Regex Does not compile: ", err)
		return
	}
	matches := r.FindStringSubmatch(scanStr)
	if len(matches) != 3 {
		return 0, log.Error("Incorrect parsing of duration string ", scanStr)
	}
	durationNum, err := strconv.Atoi(matches[1])
	if err != nil {
		return 0, log.Error("Number not in duration: ", matches[1])
	}
	durationUnit := matches[2]
	switch durationUnit {
	case "s":
		return time.Duration(durationNum) * time.Second, nil
	case "m":
		return time.Duration(durationNum) * time.Minute, nil
	case "h":
		return time.Duration(durationNum) * time.Hour, nil
	case "d":
		return time.Duration(durationNum) * 24 * time.Hour, nil
	case "M":
		return time.Duration(durationNum) * 24 * 30 * time.Hour, nil
	default:
		return 0, log.Error("Error Parsing Time unit for time: ", scanStr)
	}
}
func parseDuration ( scanStr string ) ( duration time . Duration , err error ) { r , err := regexp . Compile ( " \\ " ) if err != nil { log . Error ( " " , err ) return } matches := r . FindStringSubmatch ( scanStr ) if len ( matches ) != 3 { return 0 , log . Error ( " " , scanStr ) } durationNum , err := strconv . Atoi ( matches [ 1 ] ) if err != nil { return 0 , log . Error ( " " , matches [ 1 ] ) } durationUnit := matches [ 2 ] switch durationUnit { case " " : return time . Duration ( durationNum ) * time . Second , nil case " " : return time . Duration ( durationNum ) * time . Minute , nil case " " : return time . Duration ( durationNum ) * time . Hour , nil case " " : return time . Duration ( durationNum ) * 24 * time . Hour , nil case " " : return time . Duration ( durationNum ) * 24 * 30 * time . Hour , nil default : return 0 , log . Error ( " " , scanStr ) } }
parseDuration parses the scanEvery option into a time
parseDuration parses the scanEvery option into a time