forked from V4NSH4J/dankgrinder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.go
More file actions
31 lines (26 loc) · 705 Bytes
/
Copy pathutil.go
File metadata and controls
31 lines (26 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (C) 2021 The Dank Grinder authors.
//
// This source code has been released under the GNU Affero General Public
// License v3.0. A copy of this license is available at
// https://www.gnu.org/licenses/agpl-3.0.en.html
package main
import (
"math"
"math/rand"
"time"
"github.com/dankgrinder/dankgrinder/config"
)
// sec returns n as a time.Duration in seconds.
func sec(n int) time.Duration {
return time.Duration(n) * time.Second
}
func shiftDur(shift config.Shift) time.Duration {
if shift.Duration.Base <= 0 {
return time.Duration(math.MaxInt64)
}
d := sec(shift.Duration.Base)
if shift.Duration.Variation > 0 {
d += sec(rand.Intn(shift.Duration.Variation))
}
return d
}