add last 30 days to loose date support

This commit is contained in:
c9s 2023-07-31 17:54:34 +08:00
parent 570ccabe46
commit f2109afa0e
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -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
}