Skip to content

proposal: time: allow scientific notation in ParseDuration #67076

@spakin

Description

@spakin

Proposal Details

Issue

I encountered this issue while parsing the output of an application I was working with:

  • strconv.ParseFloat accepts numbers expressed in scientific notation. strconv.ParseFloat("3.336e-6", 64), for example, works as expected.
  • time.ParseDuration does not accept numbers expressed in scientific notation. time.ParseDuration("3.336e-6s"), for example, fails with unknown unit "e-" in duration "3.336e-6s".

A Go Playground demonstration of this limitation in time.ParseDuration can be found here: https://go.dev/play/p/G-1FveHxpZ3

Proposal

I propose that time.ParseDuration be enhanced to allow durations expressed using scientific notation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions