Skip to content

Accept one to nine fractional digits in UTC ISO 8601 parsing #673

Closed

Description

@LunaStev

Motivation

time_datetime_parse_iso8601() currently accepts only whole-second UTC timestamps or timestamps with exactly nine fractional digits. The implementation requires an input length of either 20 or 30, so otherwise valid UTC inputs with millisecond or microsecond precision are outside the supported subset.

Extend this existing API without changing the formatter or the supported timezone syntax.

Code reference: std/time/format.wave — time_datetime_parse_iso8601.

Scope

Accept YYYY-MM-DDTHH:MM:SSZ and YYYY-MM-DDTHH:MM:SS.<fraction>Z, where <fraction> contains one to nine ASCII decimal digits. Right-pad the fractional value with zeros to obtain nanoseconds; do not round or truncate excess digits.

Examples:

Input Nanoseconds
2026-09-20T12:34:56Z 0
2026-09-20T12:34:56.1Z 100000000
2026-09-20T12:34:56.123Z 123000000
2026-09-20T12:34:56.123456Z 123456000
2026-09-20T12:34:56.123456789Z 123456789

Keep the DateTimeResult API and existing calendar/time validation. The formatter must continue producing its fixed nine-digit representation, and TIME_FORMAT_ISO8601_LENGTH must remain unchanged.

Completion criteria

  • Accept every fractional length from one through nine and preserve whole-second parsing.
  • Normalize fractional values exactly, including leading zeros, trailing zeros, and an all-zero fraction.
  • Reject a decimal point with no digits, more than nine digits, non-digit fractional characters, missing or misplaced Z, and trailing input.
  • Validate the complete input shape before indexing it; short or malformed input returns the existing failure result rather than panicking.
  • Preserve rejection of invalid dates and times through time_datetime_from_parts.
  • Add runnable standard-library regressions under tests/cases/, including all supported lengths and parse-format-parse round trips.
  • Update the parser's API comment to describe the expanded subset.

Timezone offsets, lowercase separators, leap-second support, and general RFC 3339 expansion are outside this issue.

Activity

  1. added
    enhancement
    good first issue
    needs testing
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issueneeds testing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions