Skip to content

Stdlib: date()/idate()/gmdate() format B — Swatch beats wrong (ext/date/php_date.c) #12224

Closed

Description

@PurHur

Summary

date('B'), idate('B'), and gmdate('B') must return Swatch Internet Time beats (000–999) per php-src/timelib. This VM uses VmDate::swatchBeat() with a weekday-offset formula ($seconds + $daysFromMonday * 86400) instead of php-src’s ((timestamp + 3600) % 86400) / 86.4 (Biel/UTC+1 beats).

php-src reference: ext/date/php_date.c — B format branch; timelib swatch beat helper.

PHP implementation target: ext/standard/VmDate.php (swatchBeat(), idateValue(), date() B case) — port php-src formula; no new C runtime.

Repro (php-src-strict)

./script/docker-exec.sh -- bash -lc '
  php test/repro/maintainer_gap_idate_date_B_swatch.php
  php bin/vm.php test/repro/maintainer_gap_idate_date_B_swatch.php
'

Zend ($t = 1710000000): date('B') → '708'; idate('B') → 708; gmdate('B') → '708'
VM: all three → '5666' / 5666 (off by thousands)

Done when

  • date('B'), idate('B'), gmdate('B') match php-src for fixed and current timestamps.
  • Other idate() format chars unchanged.
  • Compliance .phpt; php-src-strict.

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 26, 2026
  2. PurHur commented on Jun 26, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #12225, #12224, #12223)

  3. PurHur commented on Jun 26, 2026

    @PurHur
    OwnerAuthor

    Merged via #12227. VM + JIT compliance green: date/idate/gmdate format B returns 708 for timestamp 1710000000.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions