Skip to content

Commit

Permalink
support d(ays) in config files
Browse files Browse the repository at this point in the history
  • Loading branch information
spbkaizo authored and jcmturner committed Sep 23, 2017
1 parent 6a12ba7 commit b1dc077
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config/krb5conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,16 @@ func parseETypes(s []string, w bool) []int {
// Parse a time duration string in the configuration to a golang time.Duration.
func parseDuration(s string) (time.Duration, error) {
s = strings.Replace(s, " ", "", -1)
if strings.Contains(s, "d") {
s = strings.Replace(s, "d", "", -1)
// assume this is a round number for days...
days, err := strconv.ParseInt(s, 10, 32)
if err != nil {
return time.Duration(0), errors.New("Invalid time duration.")
}
var secs = int(days) * 86400
s = strconv.Itoa(secs)
}
d, err := time.ParseDuration(s)
if err == nil {
return d, nil
Expand Down

0 comments on commit b1dc077

Please sign in to comment.