MCPcopy Create free account
hub / github.com/evcc-io/evcc / At

Method At

api/rates.go:33–48  ·  view source on GitHub ↗

At returns the rate for given timestamp or error. Rates MUST be sorted by start time.

(ts time.Time)

Source from the content-addressed store, hash-verified

31// At returns the rate for given timestamp or error.
32// Rates MUST be sorted by start time.
33func (rr Rates) At(ts time.Time) (Rate, error) {
34 if i, ok := slices.BinarySearchFunc(rr, ts, func(r Rate, ts time.Time) int {
35 switch {
36 case ts.Before(r.Start):
37 return +1
38 case !ts.Before(r.End):
39 return -1
40 default:
41 return 0
42 }
43 }); ok {
44 return rr[i], nil
45 }
46
47 return Rate{}, ErrNotAvailable
48}
49
50var _ BytesMarshaler = (*Rates)(nil)
51

Callers 7

TestRatesFunction · 0.95
UpdateMethod · 0.80
updateMethod · 0.80
smartLimitActiveMethod · 0.80
solarDetailsMethod · 0.80
AtFunction · 0.80
testInstanceFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestRatesFunction · 0.76