diff --git a/kernel/av/av.go b/kernel/av/av.go index a07ab4b50..0b87967ae 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 *Val Content: content, Content2: content2, HasEndDate: false, + IsNotTime: true, FormattedContent: formatted, } return diff --git a/kernel/av/table.go b/kernel/av/table.go index 0c0963c73..53c4fe78a 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 bool for _, 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 bool for _, 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 bool for _, 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.go index b17c6b3de..c104dab11 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 {