diff --git a/internal/merch/helper.go b/internal/merch/helper.go index 027feb1..95fdec2 100644 --- a/internal/merch/helper.go +++ b/internal/merch/helper.go @@ -3,6 +3,7 @@ package merch import ( "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" + "time" ) const ( @@ -23,3 +24,10 @@ func getUserId(c *gin.Context) int64 { id, _ := c.Get("userId") return id.(int64) } + +func getPeriod(days int) time.Time { + if days > 365 { + days = 7 + } + return time.Now().UTC().Add(-(time.Duration(days) * time.Hour * 24)) +}