factor out
This commit is contained in:
parent
8b907a5ac2
commit
b434c4172f
1 changed files with 19 additions and 0 deletions
19
internal/api/merch/helper.go
Normal file
19
internal/api/merch/helper.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package merch
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func getPeriod(days string) time.Time {
|
||||
daysInt, err := strconv.Atoi(days)
|
||||
if err != nil {
|
||||
daysInt = 7
|
||||
}
|
||||
|
||||
if daysInt > 365 {
|
||||
daysInt = 7
|
||||
}
|
||||
|
||||
return time.Now().UTC().Add(-(time.Duration(daysInt) * time.Hour * 24))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue