Skip to content

fromdateiso8601 doesn't support the "decimal fraction" component in time values. #2224

Open
@slippycheeze

Description

@slippycheeze

Describe the bug
The ISO8601 time format supports a decimal fraction attached to the smallest component present; this is passably common for seconds to represent micro- or nano-seconds. Technically this is also applicable to the minute and hour components, though I have never seen that used in the wild.

fromdateiso8601 doesn't handle fractional seconds, which is an annoyance since I have several JSON applications that emit them, and where I'd like to do some date comparisons.

To Reproduce

] jq -nr '"2020-12-11T01:00:52.605001Z" | fromdateiso8601'
jq: error (at <unknown>): date "2020-12-11T01:00:52.605001Z" does not match format "%Y-%m-%dT%H:%M:%SZ"

Expected behavior
jq(1) would parse fractional seconds; ideally, it would also carry and emit them, but just ignoring the fraction would be sufficient for my needs.

Environment (please complete the following information):

  • macOS 10.15.7 x64
  • jq-1.6

Additional context
This is definitely an extension on the basic POSIX time functions, so perhaps isn't interesting to jq. I'd hope it was, since they are fairly commonly used, but I understand if this is bounced as "not interested".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions