github.com/psexton/git-lfs@v2.1.1-0.20170517224304-289a18b2bc53+incompatible/tools/time_tools.go (about) 1 package tools 2 3 import "time" 4 5 // IsExpiredAtOrIn returns whether or not the result of calling TimeAtOrIn is 6 // "expired" within "until" units of time from now. 7 func IsExpiredAtOrIn(now time.Time, until time.Duration, at time.Time, in time.Duration) (time.Time, bool) { 8 expiration := TimeAtOrIn(now, at, in) 9 if expiration.IsZero() { 10 return expiration, false 11 } 12 13 return expiration, expiration.Before(now.Add(until)) 14 } 15 16 // TimeAtOrIn returns either "at", or the "in" duration added to the current 17 // time. TimeAtOrIn prefers to add a duration rather than return the "at" 18 // parameter. 19 func TimeAtOrIn(now, at time.Time, in time.Duration) time.Time { 20 if in == 0 { 21 return at 22 } 23 return now.Add(in) 24 }