2023-04-10 15:36:59 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2018-11-13 03:15:57 +00:00
|
|
|
package mock
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// parseDuration parses a duration string, like time.ParseDuration
|
|
|
|
// but is empty string friendly, returns a zero time duration
|
|
|
|
func parseDuration(s string) (time.Duration, error) {
|
|
|
|
if s == "" {
|
|
|
|
return time.Duration(0), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// try to parse it as duration
|
|
|
|
return time.ParseDuration(s)
|
|
|
|
}
|