time.ParseDuration does not accept scientific notation

143 views
Skip to first unread message

Scott Pakin

unread,
Apr 26, 2024, 6:38:54 PM4/26/24
to golang-nuts
While parsing output from some third-party program, I discovered that time.ParseDuration does not accept inputs expressed in scientific notation even though strconv.ParseFloat does accept such inputs. Here’s an playground example demonstrating this limitation: https://go.dev/play/p/G-1FveHxpZ3.

Any chance ParseDuration could be enhanced to accept the same numerical values as ParseFloat?

Ian Lance Taylor

unread,
Apr 26, 2024, 8:08:02 PM4/26/24
to Scott Pakin, golang-nuts
On Fri, Apr 26, 2024 at 3:39 PM Scott Pakin <scot...@pakin.org> wrote:
>
> While parsing output from some third-party program, I discovered that time.ParseDuration does not accept inputs expressed in scientific notation even though strconv.ParseFloat does accept such inputs. Here’s an playground example demonstrating this limitation: https://go.dev/play/p/G-1FveHxpZ3.
>
> Any chance ParseDuration could be enhanced to accept the same numerical values as ParseFloat?

The first step would be to open a proposal for this change. See
https://github.com/golang/proposal#readme. Thanks.

Ian

Scott Pakin

unread,
Apr 26, 2024, 11:31:52 PM4/26/24
to golang-nuts
On Friday, April 26, 2024 at 6:08:02 PM UTC-6 Ian Lance Taylor wrote:
The first step would be to open a proposal for this change. See
https://github.com/golang/proposal#readme. Thanks.

Reply all
Reply to author
Forward
0 new messages