From f2109afa0e72c1cd5e3cf92ce403055874d5626d Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 31 Jul 2023 17:54:34 +0800 Subject: [PATCH] add last 30 days to loose date support --- pkg/types/time.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/types/time.go b/pkg/types/time.go index 5bc811c85..c6e912cc5 100644 --- a/pkg/types/time.go +++ b/pkg/types/time.go @@ -256,6 +256,10 @@ func ParseLooseFormatTime(s string) (LooseFormatTime, error) { t = time.Now().AddDate(0, -1, 0) return LooseFormatTime(t), nil + case "last 30 days": + t = time.Now().AddDate(0, 0, -30) + return LooseFormatTime(t), nil + case "last year": t = time.Now().AddDate(-1, 0, 0) return LooseFormatTime(t), nil @@ -357,4 +361,3 @@ func BeginningOfTheDay(t time.Time) time.Time { func Over24Hours(since time.Time) bool { return time.Since(since) >= 24*time.Hour } -