🎨 Attribute View date column calculate https://github.com/siyuan-note/siyuan/issues/8757

This commit is contained in:
Daniel 2023-07-23 23:46:17 +08:00
parent 98f7b56c0d
commit 67aa8b642a
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 10 additions and 3 deletions

View file

@ -177,15 +177,22 @@ type ValueDate struct {
type DateFormat string
const (
DateFormatNone DateFormat = ""
DateFormatNone DateFormat = ""
DateFormatDuration DateFormat = "duration"
)
func NewFormattedValueDate(content int64, format DateFormat) (ret *ValueDate) {
formatted := time.UnixMilli(content).Format("2006-01-02 15:04")
switch format {
case DateFormatNone:
case DateFormatDuration:
formatted = time.Duration(content).String()
}
ret = &ValueDate{
Content: content,
Content2: 0,
HasEndDate: false,
FormattedContent: time.UnixMilli(content).Format("2006-01-02 15:04"),
FormattedContent: formatted,
}
return
}

View file

@ -602,7 +602,7 @@ func (table *Table) calcColDate(col *TableColumn, colIndex int) {
}
}
if 0 != earliest && 0 != latest {
col.Calc.Result = &Value{Date: NewFormattedValueDate(latest-earliest, DateFormatNone)}
col.Calc.Result = &Value{Date: NewFormattedValueDate(latest-earliest, DateFormatDuration)}
}
}
}