An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Add specific time switch to database date field https://github.com/siyuan-note/siyuan/issues/9486
Danieleb8023277196
diff --git a/kernel/av/av.go b/kernel/av/av.goindex a07ab4b50d..0b87967aec 100644--- a/kernel/av/av.go+++ b/kernel/av/av.go@@ -364,6 +364,7 @@ type ValueDate struct {Content int64 `json:"content"`IsNotEmpty bool `json:"isNotEmpty"`HasEndDate bool `json:"hasEndDate"`+ IsNotTime bool `json:"isNotTime"`Content2 int64 `json:"content2"`IsNotEmpty2 bool `json:"isNotEmpty2"`FormattedContent string `json:"formattedContent"`@@ -376,10 +377,21 @@ const (DateFormatDuration DateFormat = "duration")-func NewFormattedValueDate(content, content2 int64, format DateFormat) (ret *ValueDate) {- formatted := time.UnixMilli(content).Format("2006-01-02 15:04")+func NewFormattedValueDate(content, content2 int64, format DateFormat, isNotTime bool) (ret *ValueDate) {+ var formatted string+ if isNotTime {+ formatted = time.UnixMilli(content).Format("2006-01-02")+ } else {+ formatted = time.UnixMilli(content).Format("2006-01-02 15:04")+ }if 0 < content2 {- formatted += " → " + time.UnixMilli(content2).Format("2006-01-02 15:04")+ var formattedContent2 string+ if isNotTime {+ formattedContent2 = time.UnixMilli(content2).Format("2006-01-02")+ } else {+ formattedContent2 = time.UnixMilli(content2).Format("2006-01-02 15:04")+ }+ formatted += " → " + formattedContent2}switch format {case DateFormatNone:@@ -392,6 +404,7 @@ func NewFormattedValueDate(content, content2 int64, format DateFormat) (ret *ValContent: content,Content2: content2,HasEndDate: false,+ IsNotTime: true,FormattedContent: formatted,}returndiff --git a/kernel/av/table.go b/kernel/av/table.goindex 0c0963c73e..53c4fe78a6 100644--- a/kernel/av/table.go+++ b/kernel/av/table.go@@ -1123,43 +1123,50 @@ func (table *Table) calcColDate(col *TableColumn, colIndex int) {}case CalcOperatorEarliest:earliest := int64(0)+ var isNotTime boolfor _, row := range table.Rows {if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Date && row.Cells[colIndex].Value.Date.IsNotEmpty {if 0 == earliest || earliest > row.Cells[colIndex].Value.Date.Content {earliest = row.Cells[colIndex].Value.Date.Content+ isNotTime = row.Cells[colIndex].Value.Date.IsNotTime}}}if 0 != earliest {- col.Calc.Result = &Value{Date: NewFormattedValueDate(earliest, 0, DateFormatNone)}+ col.Calc.Result = &Value{Date: NewFormattedValueDate(earliest, 0, DateFormatNone, isNotTime)}}case CalcOperatorLatest:latest := int64(0)+ var isNotTime boolfor _, row := range table.Rows {if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Date && row.Cells[colIndex].Value.Date.IsNotEmpty {if 0 == latest || latest < row.Cells[colIndex].Value.Date.Content {latest = row.Cells[colIndex].Value.Date.Content+ isNotTime = row.Cells[colIndex].Value.Date.IsNotTime}}}if 0 != latest {- col.Calc.Result = &Value{Date: NewFormattedValueDate(latest, 0, DateFormatNone)}+ col.Calc.Result = &Value{Date: NewFormattedValueDate(latest, 0, DateFormatNone, isNotTime)}}case CalcOperatorRange:earliest := int64(0)latest := int64(0)+ var isNotTime boolfor _, row := range table.Rows {if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Date && row.Cells[colIndex].Value.Date.IsNotEmpty {if 0 == earliest || earliest > row.Cells[colIndex].Value.Date.Content {earliest = row.Cells[colIndex].Value.Date.Content+ isNotTime = row.Cells[colIndex].Value.Date.IsNotTime}if 0 == latest || latest < row.Cells[colIndex].Value.Date.Content {latest = row.Cells[colIndex].Value.Date.Content+ isNotTime = row.Cells[colIndex].Value.Date.IsNotTime}}}if 0 != earliest && 0 != latest {- col.Calc.Result = &Value{Date: NewFormattedValueDate(earliest, latest, DateFormatDuration)}+ col.Calc.Result = &Value{Date: NewFormattedValueDate(earliest, latest, DateFormatDuration, isNotTime)}}}}diff --git a/kernel/model/export.go b/kernel/model/export.goindex b17c6b3de8..c104dab116 100644--- a/kernel/model/export.go+++ b/kernel/model/export.go@@ -1946,7 +1946,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool,if nil != cell.Value {if av.KeyTypeDate == cell.Value.Type {if nil != cell.Value.Date {- cell.Value.Date = av.NewFormattedValueDate(cell.Value.Date.Content, cell.Value.Date.Content2, av.DateFormatNone)+ cell.Value.Date = av.NewFormattedValueDate(cell.Value.Date.Content, cell.Value.Date.Content2, av.DateFormatNone, cell.Value.Date.IsNotTime)}} else if av.KeyTypeCreated == cell.Value.Type {if nil != cell.Value.Created {