diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-09 00:00:12 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-09 00:00:49 +0900 |
| commit | 1c0eb589741de4aa52ef941ff9315b34dbe48aa0 (patch) | |
| tree | 8d821cf3a7fb3f8c753dec7861ad9597f6948493 /crates/shirabe/src/compiler.rs | |
| parent | e5b789616ec4c1cbd152c5ccbefe2d27ced4a18f (diff) | |
| download | php-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/src/compiler.rs')
| -rw-r--r-- | crates/shirabe/src/compiler.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/crates/shirabe/src/compiler.rs b/crates/shirabe/src/compiler.rs index 1088477..05177d6 100644 --- a/crates/shirabe/src/compiler.rs +++ b/crates/shirabe/src/compiler.rs @@ -9,8 +9,8 @@ use shirabe_external_packages::symfony::finder::Finder; use shirabe_external_packages::symfony::finder::SplFileInfo; use shirabe_php_shim::{ Phar, PhpMixed, RuntimeException, T_COMMENT, T_DOC_COMMENT, T_WHITESPACE, - UnexpectedValueException, array_search, file_exists, file_get_contents, strcmp, strtr, - strtr_array, token_get_all, + UnexpectedValueException, array_search, date_format_to_strftime, file_exists, + file_get_contents, strcmp, strtr, strtr_array, token_get_all, }; use crate::json::JsonFile; @@ -95,8 +95,7 @@ impl Compiler { let version_date_str = Git::parse_rev_list_output(&output, &process); self.version_date = chrono::DateTime::parse_from_str(version_date_str.trim(), "%Y-%m-%d %H:%M:%S %z") - .map(|dt| dt.with_timezone(&chrono::Utc)) - .unwrap_or_else(|_| chrono::Utc::now()); + .map(|dt| dt.with_timezone(&chrono::Utc))?; let mut git_describe_output = String::new(); if process.borrow_mut().execute_args( @@ -298,7 +297,12 @@ impl Compiler { // re-sign the phar with reproducible timestamp / signature let mut util = Timestamps::new(phar_file); - util.update_timestamps(&self.version_date.format("%Y-%m-%d %H:%M:%S").to_string())?; + util.update_timestamps( + &self + .version_date + .format(date_format_to_strftime("Y-m-d H:i:s")) + .to_string(), + )?; util.save(phar_file, Phar::SHA512)?; Linter::lint( @@ -355,7 +359,9 @@ impl Compiler { ); replacements.insert( "@release_date@".to_string(), - self.version_date.format("%Y-%m-%d %H:%M:%S").to_string(), + self.version_date + .format(date_format_to_strftime("Y-m-d H:i:s")) + .to_string(), ); content = strtr_array(&content, &replacements); content = Preg::replace( |
