You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
384 B
29 lines
384 B
3 years ago
|
package neo
|
||
|
|
||
|
import "time"
|
||
|
|
||
|
type moment struct {
|
||
|
when time.Time
|
||
|
do func(time time.Time)
|
||
|
}
|
||
|
|
||
|
type moments []moment
|
||
|
|
||
|
func (m moments) do(t time.Time) {
|
||
|
for _, doer := range m {
|
||
|
doer.do(t)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (m moments) Len() int {
|
||
|
return len(m)
|
||
|
}
|
||
|
|
||
|
func (m moments) Less(i, j int) bool {
|
||
|
return m[i].when.Before(m[j].when)
|
||
|
}
|
||
|
|
||
|
func (m moments) Swap(i, j int) {
|
||
|
m[i], m[j] = m[j], m[i]
|
||
|
}
|