24 lines
367 B
24 lines
367 B
package themis
|
|
|
|
import "time"
|
|
|
|
var defaultClock Clock = DefaultClock{}
|
|
|
|
type Clock interface {
|
|
Now() time.Time
|
|
}
|
|
|
|
type DefaultClock struct{}
|
|
|
|
func (DefaultClock) Now() time.Time {
|
|
return time.Now()
|
|
}
|
|
|
|
func NextWednesday(clock Clock) time.Time {
|
|
if clock == nil {
|
|
clock = defaultClock
|
|
}
|
|
now := clock.Now()
|
|
return now.AddDate(0, 0, int((10-now.Weekday())%7))
|
|
}
|