valera/internal/states/pause_bot_state/pause.go

22 lines
370 B
Go
Raw Normal View History

2023-04-09 06:31:01 +00:00
package pause_bot_state
2023-04-05 18:18:25 +00:00
import (
"strconv"
"strings"
"time"
)
2023-04-09 06:31:01 +00:00
func getDuration(text string) (time.Duration, error) {
2023-04-05 18:18:25 +00:00
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
}