From d0336078c5b63b174e7313d54d973a1832228928 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 25 Jun 2026 14:39:00 +0900 Subject: feat(external-packages,shim): implement impl todos across components Port seld/jsonlint JsonParser (+hand-written Lexer), unblocking 10 json_file parse-error tests verified byte-for-byte against PHP. Implement Symfony Finder SplFileInfo, executable finders, String classes (byte/code-point/unicode), ZipArchive shim (via the zip crate), SPDX license validation, and shim date/stream functions. Genuinely-blocked sites (reflection, PHP runtime constants, non-UTF-8 transcoding, recursive PCRE) stay todo!() with reasons. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe-php-shim/src/datetime.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'crates/shirabe-php-shim/src/datetime.rs') diff --git a/crates/shirabe-php-shim/src/datetime.rs b/crates/shirabe-php-shim/src/datetime.rs index 9810966..bddf5da 100644 --- a/crates/shirabe-php-shim/src/datetime.rs +++ b/crates/shirabe-php-shim/src/datetime.rs @@ -1,6 +1,10 @@ static DEFAULT_TIMEZONE: std::sync::Mutex> = std::sync::Mutex::new(None); pub fn date_create(s: &str) -> chrono::ParseResult> { + // TODO(phase-d): PHP `date_create` accepts the full strtotime() grammar (RFC2822, ISO8601, + // VCS-specific and relative formats), which requires a dedicated date parser not available + // here. The generic `Tz` also has no constructor from a parsed `FixedOffset`/`Utc` value. + let _ = s; todo!() } @@ -22,6 +26,8 @@ pub fn date_format_to_strftime(format: &str) -> &'static str { } pub fn strtotime(_time: &str) -> Option { + // TODO(phase-d): requires the full strtotime() grammar (absolute, relative and compound + // expressions); a partial parser would silently mis-handle unsupported inputs. todo!() } @@ -53,6 +59,17 @@ pub fn date_default_timezone_set(tz: &str) -> bool { true } -pub fn date(_format: &str, _timestamp: Option) -> String { - todo!() +pub fn date(format: &str, timestamp: Option) -> String { + let timestamp = timestamp.unwrap_or_else(time); + // PHP `date()` renders in the default timezone. Without a timezone database only "UTC" can be + // resolved; any named zone is rejected loudly rather than silently rendered in the wrong zone. + let tz = date_default_timezone_get(); + if tz != "UTC" { + panic!( + "date() with non-UTC default timezone {tz:?} is not supported (no timezone database)" + ); + } + let dt = chrono::DateTime::::from_timestamp(timestamp, 0) + .expect("date() timestamp out of range"); + dt.format(date_format_to_strftime(format)).to_string() } -- cgit v1.3.1