aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-09 00:00:12 +0900
committernsfisis <nsfisis@gmail.com>2026-06-09 00:00:49 +0900
commit1c0eb589741de4aa52ef941ff9315b34dbe48aa0 (patch)
tree8d821cf3a7fb3f8c753dec7861ad9597f6948493 /crates/shirabe-php-shim
parente5b789616ec4c1cbd152c5ccbefe2d27ced4a18f (diff)
downloadphp-shirabe-1c0eb589741de4aa52ef941ff9315b34dbe48aa0.tar.gz
php-shirabe-1c0eb589741de4aa52ef941ff9315b34dbe48aa0.tar.zst
php-shirabe-1c0eb589741de4aa52ef941ff9315b34dbe48aa0.zip
feat(datetime): resolve datetime TODOs
Introduce shim functions and constants, replacing the ad-hoc chrono format strings and parse helpers used as phase-b placeholders. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim')
-rw-r--r--crates/shirabe-php-shim/Cargo.toml1
-rw-r--r--crates/shirabe-php-shim/src/lib.rs24
2 files changed, 22 insertions, 3 deletions
diff --git a/crates/shirabe-php-shim/Cargo.toml b/crates/shirabe-php-shim/Cargo.toml
index 30e132f..b2a2077 100644
--- a/crates/shirabe-php-shim/Cargo.toml
+++ b/crates/shirabe-php-shim/Cargo.toml
@@ -5,6 +5,7 @@ edition.workspace = true
[dependencies]
anyhow.workspace = true
+chrono.workspace = true
indexmap.workspace = true
serde.workspace = true
zip.workspace = true
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs
index 835e1c1..433b8db 100644
--- a/crates/shirabe-php-shim/src/lib.rs
+++ b/crates/shirabe-php-shim/src/lib.rs
@@ -1740,8 +1740,6 @@ pub fn abs(_value: i64) -> i64 {
todo!()
}
-pub const DATE_ATOM: &str = "Y-m-d\\TH:i:sP";
-
pub fn ucfirst(_s: &str) -> String {
todo!()
}
@@ -2409,7 +2407,6 @@ pub const OPENSSL_VERSION_NUMBER: i64 = 0;
pub const OPENSSL_VERSION_TEXT: &str = "";
pub const PHP_BINARY: &str = "";
pub const PHP_WINDOWS_VERSION_BUILD: i64 = 0;
-pub const DATE_RFC3339: &str = "Y-m-d\\TH:i:sP";
pub const PREG_BACKTRACK_LIMIT_ERROR: i64 = 2;
#[derive(Debug, Clone)]
@@ -2459,3 +2456,24 @@ pub fn zlib_decode(_data: &str) -> Option<String> {
pub const STREAM_NOTIFY_FAILURE: i64 = 9;
pub const STREAM_NOTIFY_FILE_SIZE_IS: i64 = 5;
pub const STREAM_NOTIFY_PROGRESS: i64 = 7;
+
+pub fn date_create<Tz: chrono::TimeZone>(s: &str) -> chrono::ParseResult<chrono::DateTime<Tz>> {
+ todo!()
+}
+
+/// PHP: \DATE_RFC3339 ("Y-m-d\TH:i:sP").
+pub const DATE_RFC3339: &str = "%Y-%m-%dT%H:%M:%S%:z";
+
+/// PHP: \DATE_ATOM (equivalent to \DATE_RFC3339).
+pub const DATE_ATOM: &str = DATE_RFC3339;
+
+/// Convert PHP-compatible date time format to strftime-compatible format.
+/// Only the patterns Composer actually passes are supported; anything else panics.
+pub fn date_format_to_strftime(format: &str) -> &'static str {
+ match format {
+ "Y-m-d H:i:s" => "%Y-%m-%d %H:%M:%S",
+ "Y-m-d" => "%Y-%m-%d",
+ "Ymd" => "%Y%m%d",
+ other => panic!("Unsupported PHP date format: {other:?}"),
+ }
+}