2018-09-10 22:08:20 +02:00
|
|
|
package seq
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2018-12-06 16:38:58 +01:00
|
|
|
"git.gutmet.org/go-chart.git/util"
|
2018-09-10 22:08:20 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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])
|
|
|
|
}
|