This commit is contained in:
Daniel 2025-08-09 17:58:17 +08:00
parent c1682895ef
commit 96346a94ad
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 10 additions and 5 deletions

View file

@ -174,7 +174,7 @@ func sortAttributeViewGroup(avID, blockID, previousGroupID, groupID string) (err
return err return err
} }
sortGroupViews(time.Now(), view) sortGroupViews(view)
var groupView *av.View var groupView *av.View
var index, previousIndex int var index, previousIndex int

View file

@ -137,9 +137,7 @@ func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView,
} }
} }
todayStart := time.Now() sortGroupViews(view)
todayStart = time.Date(todayStart.Year(), todayStart.Month(), todayStart.Day(), 0, 0, 0, 0, time.Local)
sortGroupViews(todayStart, view)
var groups []av.Viewable var groups []av.Viewable
for _, groupView := range view.Groups { for _, groupView := range view.Groups {
@ -195,7 +193,7 @@ func hideEmptyGroupViews(view *av.View, viewable av.Viewable) {
} }
} }
func sortGroupViews(todayStart time.Time, view *av.View) { func sortGroupViews(view *av.View) {
if av.GroupOrderMan == view.Group.Order { if av.GroupOrderMan == view.Group.Order {
sort.Slice(view.Groups, func(i, j int) bool { return view.Groups[i].GroupSort < view.Groups[j].GroupSort }) sort.Slice(view.Groups, func(i, j int) bool { return view.Groups[i].GroupSort < view.Groups[j].GroupSort })
return return
@ -259,6 +257,7 @@ func sortGroupViews(todayStart time.Time, view *av.View) {
} }
startIdx := -1 startIdx := -1
todayStart := util.GetTodayStart()
thisMonth := todayStart.Format("2006-01") thisMonth := todayStart.Format("2006-01")
for i, monthGroup := range relativeDateGroups { for i, monthGroup := range relativeDateGroups {
if monthGroup.GetGroupValue() < thisMonth { if monthGroup.GetGroupValue() < thisMonth {

View file

@ -26,6 +26,12 @@ import (
"github.com/88250/go-humanize" "github.com/88250/go-humanize"
) )
func GetTodayStart() (ret time.Time) {
ret = time.Now()
ret = time.Date(ret.Year(), ret.Month(), ret.Day(), 0, 0, 0, 0, time.Local)
return
}
// Weekday returns the day of the week specified by date. // Weekday returns the day of the week specified by date.
// Sunday=0, Monday=1, ..., Saturday=6. // Sunday=0, Monday=1, ..., Saturday=6.
func Weekday(date time.Time) int { func Weekday(date time.Time) int {