days converter
This commit is contained in:
parent
1af0b68fca
commit
c772f0a4d2
1 changed files with 11 additions and 0 deletions
|
|
@ -3,6 +3,8 @@ package merch
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -31,3 +33,12 @@ func getPeriod(days int) time.Time {
|
||||||
}
|
}
|
||||||
return time.Now().UTC().Add(-(time.Duration(days) * time.Hour * 24))
|
return time.Now().UTC().Add(-(time.Duration(days) * time.Hour * 24))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDays(c *gin.Context) int {
|
||||||
|
daysQuery := strings.ToLower(c.Query("days"))
|
||||||
|
days, err := strconv.Atoi(daysQuery)
|
||||||
|
if err != nil {
|
||||||
|
days = 7
|
||||||
|
}
|
||||||
|
return days
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue