Skip to content

feat: parse ISO 8601 ordinal dates (YYYY-DDD)#132

Draft
Koan-Bot wants to merge 1 commit into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/parse-iso-ordinal-dates
Draft

feat: parse ISO 8601 ordinal dates (YYYY-DDD)#132
Koan-Bot wants to merge 1 commit into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/parse-iso-ordinal-dates

Conversation

@Koan-Bot
Copy link
Copy Markdown

@Koan-Bot Koan-Bot commented May 1, 2026

What

Add support for ISO 8601 ordinal date format (YYYY-DDD) in Date::Parse.

Why

ISO 8601 defines ordinal dates where DDD is the day-of-year (001-366). This format is commonly used in scientific data, satellite tracking (TLE), CCSDS time codes, and military contexts. Currently str2time("2025-123") returns undef.

How

  • Added a new pattern in the strptime heredoc between the ISO week date and ISO compact patterns
  • Converts ordinal day-of-year to calendar month/day using timegm/gmtime
  • Validates day range (1-366) and rejects day 366 for non-leap years
  • Supports optional time suffix (2025-123T10:30:00Z) consistent with other ISO patterns
  • Only supports the delimited form (YYYY-DDD) to avoid false positives with 7-digit numbers

Testing

  • New t/iso-ordinal-date.t with 26 tests covering:
    • Basic ordinal dates (day 1, 32, 123, 365)
    • Leap year handling (day 366 valid/invalid, Feb 29 boundary)
    • Time suffixes and fractional seconds
    • Invalid inputs (day 0, day 367)
    • Non-interference with existing YYYY-MM-DD parsing
  • Full test suite passes

Quality Report

Changes: 2 files changed, 131 insertions(+)

Code scan: clean

Tests: skipped

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Add support for ISO 8601 ordinal date format where DDD is the
day-of-year (001-366). Examples: "2025-123" = May 3, 2025.

This format is used in scientific data, satellite tracking,
military contexts, and some log formats.

Supports optional time suffix (e.g., "2025-123T10:30:00Z") and
validates day-of-year range including leap year awareness.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant