diff options
author | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
---|---|---|
committer | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
commit | 8e6be2a3092db112a5e59042b678654576d57d32 (patch) | |
tree | f390bb9f81a4e3cdcbad225e2253b4e13395a781 | |
parent | 148014c53ee125c8867a20feda2c3df8381f9460 (diff) | |
download | skaldpress-8e6be2a3092db112a5e59042b678654576d57d32.tar.gz skaldpress-8e6be2a3092db112a5e59042b678654576d57d32.zip |
Fix buggy implementation of format_time
-rw-r--r-- | smp.1 | 4 | ||||
-rw-r--r-- | src/macro_processor/macro_processor.rs | 5 |
2 files changed, 7 insertions, 2 deletions
@@ -36,6 +36,10 @@ Runs command on shell, and includes the command output in the output .IP "\fBexpr(<arg1>, <arg2>, ..., <argN>)\fR" Shorthand for running the expr command, expands all arguments, and executes it on the shell. +.IP "\fBformat_time(<format>, <time>)\fR" +Format a RFC3339-timestamp to the specified format. Format is similar to strftime. +Only available if the \fBtime\fR-feature was enabled during compilation. + .SH OPTIONS If a input file is provided, that will be processed. If not, a sort of interactive REPL will be started instead. diff --git a/src/macro_processor/macro_processor.rs b/src/macro_processor/macro_processor.rs index a5b6a59..326b28f 100644 --- a/src/macro_processor/macro_processor.rs +++ b/src/macro_processor/macro_processor.rs @@ -220,14 +220,15 @@ fn smp_builtin_indent( #[cfg(feature = "time")] fn smp_builtin_format_time( - _smp: &mut MacroProcessor, + smp: &mut MacroProcessor, macro_name: &str, args: &mut [String], ) -> Result<String, SMPError> { if args.len() < 2 { return Ok(macro_name.to_string()); } - let dt = chrono::DateTime::parse_from_rfc3339(&args[1]) + let timestamp = smp.process_input(&args[1])?; + let dt = chrono::DateTime::parse_from_rfc3339(×tamp) .map_err(|_| SMPError::UnknownError(87, None))?; Ok(format!("{}", dt.format(&args[0]))) } |