MCPcopy Index your code
hub / github.com/authorizerdev/authorizer / ParseDurationInSeconds

Function ParseDurationInSeconds

internal/utils/parser.go:9–21  ·  view source on GitHub ↗

ParseDurationInSeconds parses input s, removes ms/us/ns and returns result duration

(s string)

Source from the content-addressed store, hash-verified

7
8// ParseDurationInSeconds parses input s, removes ms/us/ns and returns result duration
9func ParseDurationInSeconds(s string) (time.Duration, error) {
10 d, err := time.ParseDuration(s)
11 if err != nil {
12 return 0, err
13 }
14
15 d = d.Truncate(time.Second)
16 if d <= 0 {
17 return 0, errors.New(`duration must be greater than 0s`)
18 }
19
20 return d, nil
21}

Callers 2

CreateAccessTokenMethod · 0.92
CreateIDTokenMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected