Skip to content

fix: Return null instead of error or today date for invalid date formats - #964

Merged
jtojnar merged 5 commits into
simplepie:masterfrom
Barnetik:fix/date-parsing-errors
Jan 16, 2026
Merged

jtojnar merged 5 commits into
simplepie:masterfrom
Barnetik:fix/date-parsing-errors

Conversation

@arraintxo

@arraintxo arraintxo commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes date parsing behavior when encountering invalid or localized date formats.

Before (PHP 7.4):

  • Invalid dates could throw errors/warnings due to strict_types

Before (PHP 8.*):

  • Invalid dates returned current date when not properly parsed (date uses current time when passed null)

After:

  • Invalid dates gracefully return null
  • Consistent behavior for different PHP versions

Changes:

  • Improved error handling in date parsing
  • Added test coverage for RFC 2822 formatted dates
  • Added test for custom format parameter

@jtojnar jtojnar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks great, just few notes.

Comment thread src/Item.php Resolved
Comment thread tests/Unit/ItemTest.php Resolved
Comment thread tests/Unit/ItemTest.php Resolved
@jtojnar jtojnar added this to the 1.10.0 milestone Jan 15, 2026
@arraintxo

Copy link
Copy Markdown
Contributor Author

I'm having some issues merging your suggestions, will try again later. I guess I should have batched all in one from the beginning. I'm not used to this github functionality, sorry for the annoyance.

@arraintxo

Copy link
Copy Markdown
Contributor Author

@jtojnar applied your last suggestions manually as github didn't allow me to merge them any more, but everything should be OK now.

Thank you!

@jtojnar
jtojnar merged commit 63bd4b7 into simplepie:master Jan 16, 2026
10 checks passed
@jtojnar

jtojnar commented Jan 16, 2026

Copy link
Copy Markdown
Member

Thank you, nicely done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants