go-chart/seq/times.go
2018-12-06 16:38:58 +01:00

32 lines
591 B
Go

package seq
import (
"time"
"git.gutmet.org/go-chart.git/util"
)
// Assert types implement interfaces.
var (
_ Provider = (*Times)(nil)
)
// Times are an array of times.
// It wraps the array with methods that implement `seq.Provider`.
type Times []time.Time
// Array returns the times to an array.
func (t Times) Array() []time.Time {
return []time.Time(t)
}
// Len returns the length of the array.
func (t Times) Len() int {
return len(t)
}
// GetValue returns a value at an index as a time.
func (t Times) GetValue(index int) float64 {
return util.Time.ToFloat64(t[index])
}