Use new FormatTime for X-axis labels and last_updated

pull/206/head
Simon Roberts 3 years ago
parent 9e910402f5
commit aece767608
No known key found for this signature in database
GPG Key ID: 0F30F99E6B771FD4

@ -291,7 +291,7 @@ func (ct *Cointop) GetCoinsTable() *table.Table {
})
case "last_updated":
unix, _ := strconv.ParseInt(coin.LastUpdated, 10, 64)
lastUpdated := time.Unix(unix, 0).Format("15:04:05 Jan 02")
lastUpdated := humanize.FormatTime(time.Unix(unix, 0), "15:04:05 Jan 02")
ct.SetTableColumnWidthFromString(header, lastUpdated)
ct.SetTableColumnAlignLeft(header, false)
rowCells = append(rowCells,

@ -290,7 +290,7 @@ func (ct *Cointop) GetPortfolioTable() *table.Table {
})
case "last_updated":
unix, _ := strconv.ParseInt(coin.LastUpdated, 10, 64)
lastUpdated := time.Unix(unix, 0).Format("15:04:05 Jan 02")
lastUpdated := humanize.FormatTime(time.Unix(unix, 0), "15:04:05 Jan 02")
ct.SetTableColumnWidthFromString(header, lastUpdated)
ct.SetTableColumnAlignLeft(header, false)
rowCells = append(rowCells,

@ -4,6 +4,8 @@ import (
"math"
"sort"
"time"
"github.com/cointop-sh/cointop/pkg/humanize"
)
// ResampleTimeSeriesData resamples the given [timestamp,value] data to numsteps between start-end (returns numSteps+1 points).
@ -59,7 +61,8 @@ func BuildTimeSeriesLabels(data [][]float64) []string {
}
var labels []string
for i := range data {
labels = append(labels, time.UnixMilli(int64(data[i][0])).Format(timeFormat))
labelTime := time.UnixMilli(int64(data[i][0]))
labels = append(labels, humanize.FormatTime(labelTime, timeFormat))
}
return labels
}

Loading…
Cancel
Save