Skip to content

Time\Duration - #23073

Open
TimWolla wants to merge 3 commits into
php:masterfrom
TimWolla:time-duration
Open

Time\Duration#23073
TimWolla wants to merge 3 commits into
php:masterfrom
TimWolla:time-duration

Conversation

@TimWolla

@TimWolla TimWolla commented Aug 5, 2026

Copy link
Copy Markdown
Member

Comment thread ext/date/config0.m4 Outdated
Comment thread ext/date/time_duration.c
Comment thread ext/date/php_date_time_duration.c Outdated
Comment thread ext/date/time_duration.c Outdated
Comment thread ext/date/php_date_time_duration.c Outdated
Comment thread ext/date/time_duration.c Outdated
Comment thread ext/date/tests/time/duration/fromNanoseconds_64.phpt Outdated
Comment thread ext/date/php_date_time_duration.c Outdated
Comment thread ext/date/time_duration.c
Comment thread ext/date/time_duration.c Outdated
Comment thread ext/date/php_date_time_duration.c Outdated

php_date_time_duration *original = Z_DATE_TIME_DURATION_P(ZEND_THIS);
php_date_time_duration *additional = php_date_time_duration_from_obj(duration);
php_date_time_duration *new = Z_DATE_TIME_DURATION_P(return_value);

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.

When either original or additional has recount==1, it may be possible to reuse it?

Comment thread ext/date/time_duration.c Outdated
@TimWolla
TimWolla force-pushed the time-duration branch 8 times, most recently from ebb8107 to 5f203d8 Compare August 5, 2026 20:09
@TimWolla TimWolla added the RFC label Aug 5, 2026
@TimWolla
TimWolla requested review from arnaud-lb and derickr August 5, 2026 20:16
@TimWolla
TimWolla force-pushed the time-duration branch 2 times, most recently from 89e45ab to 6390166 Compare August 5, 2026 20:43
Comment thread ext/date/tests/time/duration/methods/add.phpt Outdated
Comment thread ext/date/tests/time/duration/methods/div.phpt Outdated
Comment thread ext/date/tests/time/duration/methods/mul.phpt Outdated
Comment thread ext/date/php_time.c
Comment thread ext/date/php_time.c Outdated
Comment thread ext/date/php_time.h Outdated
Comment thread ext/date/php_time.h Outdated
@TimWolla
TimWolla force-pushed the time-duration branch 2 times, most recently from 95eee76 to a2a58e7 Compare August 6, 2026 08:23
Comment thread ext/date/tests/time/duration/methods/fromIso8601DurationString.phpt Outdated
Comment thread ext/date/lib/duration.c
Comment thread ext/date/php_date.h Outdated
Comment thread ext/date/php_time.h
Comment thread ext/date/time_duration.c
Comment thread ext/date/time_duration.c
Comment thread ext/date/time_duration.c Outdated
Comment thread ext/date/time_duration.c
@TimWolla
TimWolla marked this pull request as ready for review August 6, 2026 14:39
TimWolla and others added 3 commits August 6, 2026 18:02
…om*()`

This is useful for patterns like the following:

    for (;;) {
        $watchers = $poll->wait(Time\Duration::fromSeconds(1));
        // …
    }

which is repeatedly creating identical duration objects for every loop
iteration.

@arnaud-lb arnaud-lb 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.

Looks good to me otherwise

Comment thread ext/date/time_duration.c Outdated
Comment thread ext/date/time_duration.c
Comment thread ext/date/time_duration.c Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants