package pause_bot_state import ( "strconv" "strings" "time" ) func getDuration(text string) (time.Duration, error) { d := strings.TrimSuffix(text, "ч") d = strings.TrimSuffix(d, "д") count, err := strconv.Atoi(d) if err != nil { return 0, err } res := time.Duration(count) * time.Hour if strings.HasSuffix(text, "д") { res *= 24 } return res, nil }