Repository navigation
Labels
area:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsPhase 4 – stdlib for web apps
Description
Category
stdlib
Problem
Procedural solar-position helpers date_sunrise() and date_sunset() compute local sunrise/sunset timestamps from geographic coordinates. They live in ext/date alongside date() / strtotime() but are not registered here (function_exists('date_sunrise') → false, verified Jun 2026).
Related procedural gaps: #3292 (strtotime/mktime), #3504 (timezone introspection).
php-src reference
ext/date/php_date.c—PHP_FUNCTION(date_sunrise),PHP_FUNCTION(date_sunset)ext/date/lib/astro.c— solar algorithm (shared withdate_sun_info())- Constants:
SUNFUNCS_RET_TIMESTAMP,SUNFUNCS_RET_STRING,SUNFUNCS_RET_DOUBLE
Repro (failure today)
<?php
date_default_timezone_set('UTC');
$ts = date_sunrise(mktime(0, 0, 0, 6, 21, 2026), SUNFUNCS_RET_TIMESTAMP, 51.5, -0.1, 90, 0);
echo is_int($ts) || is_float($ts) ? 'ok' : 'fail', "\n";./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
php repro.php| Runtime | Output |
|---|---|
| Zend PHP 8.x | ok (numeric timestamp) |
bin/vm.php |
Call to undefined function date_sunrise() |
Scope (this repo)
| Area | Path | Notes |
|---|---|---|
| Stdlib | ext/date/date_sunrise.php, date_sunset.php or ext/standard/ |
v1 may delegate to host date_sunrise in VM |
| Constants | ext/date/DateConstants.php |
SUNFUNCS_* |
| Tests | test/compliance/cases/date/sunrise_sunset.phpt |
Compare numeric output to Zend (tolerance OK) |
| JIT/AOT | VM-first v1 | Document deferral |
Defer date_sun_info() OOP to phase 2 (same astro.c).
Done when
- Repro prints
okon VM with timestamp within ±60s of Zend on same inputs -
SUNFUNCS_RET_STRINGandSUNFUNCS_RET_DOUBLEmodes supported - Invalid latitude/longitude →
falselike Zend -
./script/ci-fast.sh --filter date_sunrisegreen
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter date_sunrise'Links
- Procedural date: Stdlib: strtotime() / mktime() / checkdate() / date_default_timezone_* — procedural date parsing (ext/date parity) #3292
- OOP date: Stdlib: DateTime / DateTimeImmutable OOP (ext/date parity) #3072, Stdlib: DateTimeImmutable / DateInterval — ext/date OOP phase 2 (#3072 follow-up) #3162
- North star: Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492
Metadata
Metadata
Assignees
Labels
area:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsPhase 4 – stdlib for web apps
Activity
PurHur commentedon Jun 11, 2026
claim: PHP Runtime → PHP — starting this run (#6137: date_sunrise/date_sunset VM builtins via VmDate host bridge).
php-in-php: date_sunrise()/date_sunset() VM builtins via VmDate host …
PurHur commentedon Jun 11, 2026
Merged via #7965.
Verification
VM repro: rise_ok/set_ok + timestamps 1782013676/1782072990 matching Zend.
PHPUnit: OK (2 tests, 2 assertions).
PHP path: ext/standard/VmDate.php, date_sunrise.php, date_sunset.php, VmDateSunFunc.php
C runtime: no new C (phpc_progress.c only remains frozen ABI).
Stdlib: JIT/AOT lowering for date_sunrise()/date_sunset() (#6137). (#…
PurHur commentedon Jun 12, 2026
Merged via #8125.
Implementation:
ext/standard/JitDateSunFunc.php— compile-time literal baking overVmDateSunNative(php-srcext/date/php_date.c+ext/date/lib/astro.c). Supporting fixes:compileTimeFloatpropagation through unary-and temporary boxing (lib/JIT.php,JitUnaryMinus.php,Variable.php).Verification (Docker):
vendor/bin/phpunit --filter date_sunrise_sunset test/compliance/VMTest.php— OK (VM + JIT PHPT)vendor/bin/phpunit --filter date_sunrise_sunset test/aot/AotTest.php— OK (AOT link + execute)php bin/compile.php -o /tmp/sun …withdate_sunrise(1782000000, 0, 51.5, -0.1, 90.0, 0.0)→1782013676