mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🐛 Date field does not respect end time switch when exporting database block https://github.com/siyuan-note/siyuan/issues/10409
This commit is contained in:
parent
2b2aced238
commit
d2dc9623a7
3 changed files with 15 additions and 11 deletions
|
|
@ -1298,50 +1298,54 @@ func (table *Table) calcColDate(col *TableColumn, colIndex int) {
|
||||||
}
|
}
|
||||||
case CalcOperatorEarliest:
|
case CalcOperatorEarliest:
|
||||||
earliest := int64(0)
|
earliest := int64(0)
|
||||||
var isNotTime bool
|
var isNotTime, hasEndDate bool
|
||||||
for _, row := range table.Rows {
|
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 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 {
|
if 0 == earliest || earliest > row.Cells[colIndex].Value.Date.Content {
|
||||||
earliest = row.Cells[colIndex].Value.Date.Content
|
earliest = row.Cells[colIndex].Value.Date.Content
|
||||||
isNotTime = row.Cells[colIndex].Value.Date.IsNotTime
|
isNotTime = row.Cells[colIndex].Value.Date.IsNotTime
|
||||||
|
hasEndDate = row.Cells[colIndex].Value.Date.HasEndDate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if 0 != earliest {
|
if 0 != earliest {
|
||||||
col.Calc.Result = &Value{Date: NewFormattedValueDate(earliest, 0, DateFormatNone, isNotTime)}
|
col.Calc.Result = &Value{Date: NewFormattedValueDate(earliest, 0, DateFormatNone, isNotTime, hasEndDate)}
|
||||||
}
|
}
|
||||||
case CalcOperatorLatest:
|
case CalcOperatorLatest:
|
||||||
latest := int64(0)
|
latest := int64(0)
|
||||||
var isNotTime bool
|
var isNotTime, hasEndDate bool
|
||||||
for _, row := range table.Rows {
|
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 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 {
|
if 0 == latest || latest < row.Cells[colIndex].Value.Date.Content {
|
||||||
latest = row.Cells[colIndex].Value.Date.Content
|
latest = row.Cells[colIndex].Value.Date.Content
|
||||||
isNotTime = row.Cells[colIndex].Value.Date.IsNotTime
|
isNotTime = row.Cells[colIndex].Value.Date.IsNotTime
|
||||||
|
hasEndDate = row.Cells[colIndex].Value.Date.HasEndDate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if 0 != latest {
|
if 0 != latest {
|
||||||
col.Calc.Result = &Value{Date: NewFormattedValueDate(latest, 0, DateFormatNone, isNotTime)}
|
col.Calc.Result = &Value{Date: NewFormattedValueDate(latest, 0, DateFormatNone, isNotTime, hasEndDate)}
|
||||||
}
|
}
|
||||||
case CalcOperatorRange:
|
case CalcOperatorRange:
|
||||||
earliest := int64(0)
|
earliest := int64(0)
|
||||||
latest := int64(0)
|
latest := int64(0)
|
||||||
var isNotTime bool
|
var isNotTime, hasEndDate bool
|
||||||
for _, row := range table.Rows {
|
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 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 {
|
if 0 == earliest || earliest > row.Cells[colIndex].Value.Date.Content {
|
||||||
earliest = row.Cells[colIndex].Value.Date.Content
|
earliest = row.Cells[colIndex].Value.Date.Content
|
||||||
isNotTime = row.Cells[colIndex].Value.Date.IsNotTime
|
isNotTime = row.Cells[colIndex].Value.Date.IsNotTime
|
||||||
|
hasEndDate = row.Cells[colIndex].Value.Date.HasEndDate
|
||||||
}
|
}
|
||||||
if 0 == latest || latest < row.Cells[colIndex].Value.Date.Content {
|
if 0 == latest || latest < row.Cells[colIndex].Value.Date.Content {
|
||||||
latest = row.Cells[colIndex].Value.Date.Content
|
latest = row.Cells[colIndex].Value.Date.Content
|
||||||
isNotTime = row.Cells[colIndex].Value.Date.IsNotTime
|
isNotTime = row.Cells[colIndex].Value.Date.IsNotTime
|
||||||
|
hasEndDate = row.Cells[colIndex].Value.Date.HasEndDate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if 0 != earliest && 0 != latest {
|
if 0 != earliest && 0 != latest {
|
||||||
col.Calc.Result = &Value{Date: NewFormattedValueDate(earliest, latest, DateFormatDuration, isNotTime)}
|
col.Calc.Result = &Value{Date: NewFormattedValueDate(earliest, latest, DateFormatDuration, isNotTime, hasEndDate)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ const (
|
||||||
DateFormatDuration DateFormat = "duration"
|
DateFormatDuration DateFormat = "duration"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewFormattedValueDate(content, content2 int64, format DateFormat, isNotTime bool) (ret *ValueDate) {
|
func NewFormattedValueDate(content, content2 int64, format DateFormat, isNotTime, hasEndDate bool) (ret *ValueDate) {
|
||||||
var formatted string
|
var formatted string
|
||||||
contentTime := time.UnixMilli(content)
|
contentTime := time.UnixMilli(content)
|
||||||
if 0 == content || contentTime.IsZero() {
|
if 0 == content || contentTime.IsZero() {
|
||||||
|
|
@ -321,7 +321,7 @@ func NewFormattedValueDate(content, content2 int64, format DateFormat, isNotTime
|
||||||
formatted = contentTime.Format("2006-01-02 15:04")
|
formatted = contentTime.Format("2006-01-02 15:04")
|
||||||
}
|
}
|
||||||
|
|
||||||
if 0 < content2 {
|
if hasEndDate {
|
||||||
var formattedContent2 string
|
var formattedContent2 string
|
||||||
content2Time := time.UnixMilli(content2)
|
content2Time := time.UnixMilli(content2)
|
||||||
if isNotTime {
|
if isNotTime {
|
||||||
|
|
@ -343,7 +343,7 @@ func NewFormattedValueDate(content, content2 int64, format DateFormat, isNotTime
|
||||||
ret = &ValueDate{
|
ret = &ValueDate{
|
||||||
Content: content,
|
Content: content,
|
||||||
Content2: content2,
|
Content2: content2,
|
||||||
HasEndDate: false,
|
HasEndDate: hasEndDate,
|
||||||
IsNotTime: true,
|
IsNotTime: true,
|
||||||
FormattedContent: formatted,
|
FormattedContent: formatted,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ func ExportAv2CSV(avID string) (zipPath string, err error) {
|
||||||
if nil != cell.Value {
|
if nil != cell.Value {
|
||||||
if av.KeyTypeDate == cell.Value.Type {
|
if av.KeyTypeDate == cell.Value.Type {
|
||||||
if nil != cell.Value.Date {
|
if nil != cell.Value.Date {
|
||||||
cell.Value.Date = av.NewFormattedValueDate(cell.Value.Date.Content, cell.Value.Date.Content2, av.DateFormatNone, cell.Value.Date.IsNotTime)
|
cell.Value.Date = av.NewFormattedValueDate(cell.Value.Date.Content, cell.Value.Date.Content2, av.DateFormatNone, cell.Value.Date.IsNotTime, cell.Value.Date.HasEndDate)
|
||||||
}
|
}
|
||||||
} else if av.KeyTypeCreated == cell.Value.Type {
|
} else if av.KeyTypeCreated == cell.Value.Type {
|
||||||
if nil != cell.Value.Created {
|
if nil != cell.Value.Created {
|
||||||
|
|
@ -2274,7 +2274,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool,
|
||||||
if nil != cell.Value {
|
if nil != cell.Value {
|
||||||
if av.KeyTypeDate == cell.Value.Type {
|
if av.KeyTypeDate == cell.Value.Type {
|
||||||
if nil != cell.Value.Date {
|
if nil != cell.Value.Date {
|
||||||
cell.Value.Date = av.NewFormattedValueDate(cell.Value.Date.Content, cell.Value.Date.Content2, av.DateFormatNone, cell.Value.Date.IsNotTime)
|
cell.Value.Date = av.NewFormattedValueDate(cell.Value.Date.Content, cell.Value.Date.Content2, av.DateFormatNone, cell.Value.Date.IsNotTime, cell.Value.Date.HasEndDate)
|
||||||
}
|
}
|
||||||
} else if av.KeyTypeCreated == cell.Value.Type {
|
} else if av.KeyTypeCreated == cell.Value.Type {
|
||||||
if nil != cell.Value.Created {
|
if nil != cell.Value.Created {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue