Skip to content

Stdlib: DateTime::diff() / DateTimeImmutable::diff() VM methods (#3162) - #8454

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-datetime-diff-3162
Jun 14, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-datetime-diff-3162

Conversation

@PurHur

@PurHur PurHur commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Register DateTime::diff() and DateTimeImmutable::diff() on the VM, delegating to existing DateTimeSupport::diffDateTimes() (php-src php_date_diff / zim_DateTime_diff).
  • Add compliance PHPT and maintainer repro; day counts match Zend PHP 8.2.

php-src reference

  • ext/date/php_date.c — PHP_METHOD(DateTime, diff), php_date_diff()

Verification

docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_datetime_diff.php
php bin/vm.php test/repro-maintainer/parity_datetime_diff.php
vendor/bin/phpunit --filter datetime_diff
php bin/compile.php -l test/repro-maintainer/parity_datetime_diff.php
'

Output (VM repro):

7
forward
7

PHPUnit: OK (2 tests, 2 assertions)

AOT compile-only (-l) passes. Full native AOT execution of DateTime::diff() remains blocked on DateTime method JIT lowering (#4043), same as other DateTime OOP methods.

Closes #3162 (partial — OOP diff(); DatePeriod / full JIT/AOT tracked separately).

Made with Cursor

Wire OOP diff() for DateTime and DateTimeImmutable via existing php_date_diff
logic; add compliance PHPT and maintainer repro matching Zend day counts.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit c6dfbe0 into master Jun 14, 2026
@PurHur
PurHur deleted the agent/stdlib-datetime-diff-3162 branch June 14, 2026 00:54
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.

Stdlib: DateTimeImmutable / DateInterval — ext/date OOP phase 2 (#3072 follow-up)

1 participant