-
Notifications
You must be signed in to change notification settings - Fork 3
Description
The following was taken from jerf via this reddit post:
GetFutureDateByFiveMinuteIntervalPattern and all its friends can be implemented as a GetFutureDate(interval time.Duration) time.Time and a GetFutureDateFrom(interval time.Duration, baseTime time.Time) time.Time. Look at the time.Truncate option. The first function can work by Truncating time.Now() to the given interval, then advancing one interval. The second can work with a bit more math around computing how far off the default truncated time the base time is. e.g., I should be able to call GetFutureDateFrom(50 * time.Minute, noonPlusOneMinute) and get a time with a 1 in the ones digit of the time (05:01, 07:31, etc).
Your tests are going to end up being not generally extensive enough. Speaking from experience, you're going to want to write tests that step through every possible time based on whatever interval you're testing (minutes, days, etc.), and also, one time exactly on the interval in question (e.g., exactly noon) and a time not exactly on the given interval (e.g., noon + 50 milliseconds, noon + 1 second), to test the behavior on the boundaries. I have no specific knowledge of what bug