This commit is contained in:
Daniel 2025-07-26 10:11:15 +08:00
parent 04587ca695
commit a76a520996
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1674,25 +1674,25 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {
// 过去 30 天之前的按月分组
// 过去 30 天、过去 7 天、昨天、今天、明天、未来 7 天、未来 30 天
// 未来 30 天之后的按月分组
now := time.Now()
now = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
if contentTime.Before(now.AddDate(0, 0, -30)) {
todayStart := time.Now()
todayStart = time.Date(todayStart.Year(), todayStart.Month(), todayStart.Day(), 0, 0, 0, 0, time.Local)
if contentTime.Before(todayStart.AddDate(0, 0, -30)) {
groupName = contentTime.Format("2006-01")
} else if contentTime.Before(now.AddDate(0, 0, -7)) {
} else if contentTime.Before(todayStart.AddDate(0, 0, -7)) {
groupName = groupNameLast30Days
} else if contentTime.Before(now.AddDate(0, 0, -1)) {
} else if contentTime.Before(todayStart.AddDate(0, 0, -1)) {
groupName = groupNameLast7Days
} else if contentTime.Before(now) {
} else if contentTime.Before(todayStart) {
groupName = groupNameYesterday
} else if contentTime.After(now) && contentTime.Before(now.AddDate(0, 0, 1)) {
} else if contentTime.After(todayStart) && contentTime.Before(todayStart.AddDate(0, 0, 1)) {
groupName = groupNameToday
} else if contentTime.After(now.AddDate(0, 0, 1)) || contentTime.Equal(now.AddDate(0, 0, 1)) {
} else if (contentTime.After(todayStart.AddDate(0, 0, 1)) && contentTime.Before(todayStart.AddDate(0, 0, 2))) || contentTime.Equal(todayStart.AddDate(0, 0, 1)) {
groupName = groupNameTomorrow
} else if contentTime.After(now.AddDate(0, 0, 30)) {
} else if contentTime.After(todayStart.AddDate(0, 0, 30)) {
groupName = contentTime.Format("2006-01")
} else if contentTime.After(now.AddDate(0, 0, 7)) {
} else if contentTime.After(todayStart.AddDate(0, 0, 7)) {
groupName = groupNameNext30Days
} else if contentTime.After(now.AddDate(0, 0, 1)) {
} else if contentTime.After(todayStart.AddDate(0, 0, 1)) {
groupName = groupNameNext7Days
}
}