From c772f0a4d2eeecf907b4f3d8dc244db38ce62d6d Mon Sep 17 00:00:00 2001 From: nquidox Date: Tue, 10 Mar 2026 23:43:49 +0300 Subject: [PATCH] days converter --- internal/merch/helper.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/merch/helper.go b/internal/merch/helper.go index 95fdec2..68396e2 100644 --- a/internal/merch/helper.go +++ b/internal/merch/helper.go @@ -3,6 +3,8 @@ package merch import ( "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" + "strconv" + "strings" "time" ) @@ -31,3 +33,12 @@ func getPeriod(days int) time.Time { } 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 +}