Skip to content

Fix RFC 3339 date-time validation with high-precision fractional seconds - #940

Open
UmairRathore wants to merge 1 commit into
jsonrainbow:mainfrom
UmairRathore:fix/929-rfc3339-fractional-seconds
Open

Fix RFC 3339 date-time validation with high-precision fractional seconds#940
UmairRathore wants to merge 1 commit into
jsonrainbow:mainfrom
UmairRathore:fix/929-rfc3339-fractional-seconds

Conversation

@UmairRathore

Copy link
Copy Markdown

Description

Fix RFC 3339 date-time validation for timestamps containing more than six fractional-second digits.

RFC 3339 allows one or more digits in the fractional-second component, but PHP's DateTimeImmutable::createFromFormat() only accepts up to six microsecond digits.

The full input continues to be validated by the existing RFC 3339 pattern. Only the fractional component passed internally to DateTimeImmutable is truncated to six digits, avoiding PHP's parser limitation without rejecting otherwise valid RFC 3339 timestamps.

Regression tests have been added for fractional seconds beyond six digits, including timezone offsets.

Related Issue

Fixes #929

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Other (please describe):

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the code style of this project
  • I have added tests that prove my fix is effective or that my feature works
  • All new and existing tests pass
  • I have updated the documentation accordingly
  • My changes generate no new warnings

Additional Notes

Tested with:

  • Targeted RFC 3339 tests: 16 tests, 26 assertions
  • Targeted format constraint tests: 162 tests, 180 assertions
  • Full test suite: 3165 tests, 9808 assertions, 1 existing warning, 11 skipped
  • PHPStan: 157/157 files, no errors

The existing PHPUnit warning is unchanged from the pre-change baseline.

@UmairRathore UmairRathore changed the title Fix date-time validation for fractional seconds beyond microseconds Fix RFC 3339 date-time validation with high-precision fractional seconds Aug 22, 2026
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.

date-time validation fails if more than 6 fractional second digits supplied

1 participant