move contribution from ledger to ana
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package ana
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func predictionTimes(window time.Duration) []time.Time {
|
||||
result := []time.Time{}
|
||||
@@ -11,3 +14,23 @@ func predictionTimes(window time.Duration) []time.Time {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func mustDateToTime(s string) time.Time {
|
||||
result, err := dateToTime(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func dateToTime(s string) (time.Time, error) {
|
||||
for _, layout := range []string{
|
||||
"2006-01-02",
|
||||
"2006-01",
|
||||
} {
|
||||
if t, err := time.ParseInLocation(layout, s, time.Local); err == nil {
|
||||
return t, err
|
||||
}
|
||||
}
|
||||
return time.Time{}, fmt.Errorf("no layout matching %q", s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user