mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-10 01:04:21 +01:00
🎨 Add specific time switch to database date field https://github.com/siyuan-note/siyuan/issues/9486
This commit is contained in:
parent
ee50814189
commit
eb80232771
3 changed files with 27 additions and 7 deletions
|
|
@ -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)}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue