Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
b5bf94e68a
2 changed files with 19 additions and 7 deletions
|
@ -177,15 +177,27 @@ type ValueDate struct {
|
|||
type DateFormat string
|
||||
|
||||
const (
|
||||
DateFormatNone DateFormat = ""
|
||||
DateFormatNone DateFormat = ""
|
||||
DateFormatDuration DateFormat = "duration"
|
||||
)
|
||||
|
||||
func NewFormattedValueDate(content int64, format DateFormat) (ret *ValueDate) {
|
||||
func NewFormattedValueDate(content, content2 int64, format DateFormat) (ret *ValueDate) {
|
||||
formatted := time.UnixMilli(content).Format("2006-01-02 15:04")
|
||||
if 0 < content2 {
|
||||
formatted += " → " + time.UnixMilli(content2).Format("2006-01-02 15:04")
|
||||
}
|
||||
switch format {
|
||||
case DateFormatNone:
|
||||
case DateFormatDuration:
|
||||
t1 := time.UnixMilli(content)
|
||||
t2 := time.UnixMilli(content2)
|
||||
formatted = util.HumanizeRelTime(t1, t2, util.Lang)
|
||||
}
|
||||
ret = &ValueDate{
|
||||
Content: content,
|
||||
Content2: 0,
|
||||
Content2: content2,
|
||||
HasEndDate: false,
|
||||
FormattedContent: time.UnixMilli(content).Format("2006-01-02 15:04:05"),
|
||||
FormattedContent: formatted,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -574,7 +574,7 @@ func (table *Table) calcColDate(col *TableColumn, colIndex int) {
|
|||
}
|
||||
}
|
||||
if 0 != earliest {
|
||||
col.Calc.Result = &Value{Date: NewFormattedValueDate(earliest, DateFormatNone)}
|
||||
col.Calc.Result = &Value{Date: NewFormattedValueDate(earliest, 0, DateFormatNone)}
|
||||
}
|
||||
case CalcOperatorLatest:
|
||||
latest := int64(0)
|
||||
|
@ -586,7 +586,7 @@ func (table *Table) calcColDate(col *TableColumn, colIndex int) {
|
|||
}
|
||||
}
|
||||
if 0 != latest {
|
||||
col.Calc.Result = &Value{Date: NewFormattedValueDate(latest, DateFormatNone)}
|
||||
col.Calc.Result = &Value{Date: NewFormattedValueDate(latest, 0, DateFormatNone)}
|
||||
}
|
||||
case CalcOperatorRange:
|
||||
earliest := int64(0)
|
||||
|
@ -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(earliest, latest, DateFormatDuration)}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue