-
Notifications
You must be signed in to change notification settings - Fork 63
Closed
Description
The OpenAPI definition of the duration format follows RFC 3339. The definition here is more relaxed, which is nice, but IsDuration allows text that produces unexpected values from ParseDuration and unmarshaling.
https://go.dev/play/p/0MhAO3Ife4I
I expected 1.5 hours
to be 90 minutes, but this valid text is interpreted as 5 hours:
fmt.Println(time.ParseDuration("1.5h")) // 1h30m0s <nil>
fmt.Println(strfmt.ParseDuration("1.5 hours")) // 5h0m0s <nil>
I expected 1.5 days
to be 36 hours, but this valid text is interpreted as 120 hours:
fmt.Println(strfmt.ParseDuration("1.5 days")) // 120h0m0s <nil>
fmt.Println(1.5 * 24 * time.Hour) // 36h0m0s
Metadata
Metadata
Assignees
Labels
No labels