mirror of
https://github.com/datarhei/core.git
synced 2025-10-04 23:53:12 +08:00
Replace timer-based SMA with a timer-less implementation
This commit is contained in:
25
time/source.go
Normal file
25
time/source.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package time
|
||||
|
||||
import "time"
|
||||
|
||||
type Source interface {
|
||||
Now() time.Time
|
||||
}
|
||||
|
||||
type StdSource struct{}
|
||||
|
||||
func (s *StdSource) Now() time.Time {
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
type TestSource struct {
|
||||
N time.Time
|
||||
}
|
||||
|
||||
func (t *TestSource) Now() time.Time {
|
||||
return t.N
|
||||
}
|
||||
|
||||
func (t *TestSource) Set(sec int64, nsec int64) {
|
||||
t.N = time.Unix(sec, nsec)
|
||||
}
|
Reference in New Issue
Block a user