🎨 Improve database date filed sorting https://github.com/siyuan-note/siyuan/issues/12127
This commit is contained in:
parent
9a8802bf39
commit
e5078e8af5
1 changed files with 16 additions and 2 deletions
|
@ -19,6 +19,7 @@ package av
|
|||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
@ -84,10 +85,23 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {
|
|||
if !other.Date.IsNotEmpty {
|
||||
return -1
|
||||
}
|
||||
if value.Date.Content > other.Date.Content {
|
||||
|
||||
valueContent := value.Date.Content
|
||||
otherContent := other.Date.Content
|
||||
|
||||
if value.Date.IsNotTime {
|
||||
v := time.UnixMilli(valueContent)
|
||||
valueContent = time.Date(v.Year(), v.Month(), v.Day(), 0, 0, 0, 0, time.Local).UnixMilli()
|
||||
}
|
||||
if other.Date.IsNotTime {
|
||||
o := time.UnixMilli(otherContent)
|
||||
otherContent = time.Date(o.Year(), o.Month(), o.Day(), 0, 0, 0, 0, time.Local).UnixMilli()
|
||||
}
|
||||
|
||||
if valueContent > otherContent {
|
||||
return 1
|
||||
}
|
||||
if value.Date.Content < other.Date.Content {
|
||||
if valueContent < otherContent {
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
|
|
Loading…
Add table
Reference in a new issue