Allow int input when using a formatstring

This commit is contained in:
NotTheDr01ds 2024-08-05 07:52:21 -04:00
parent 07e7c8c81f
commit 2ad05d3dd6

View File

@ -379,8 +379,8 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value {
// If input is not a timestamp, try parsing it as a string // If input is not a timestamp, try parsing it as a string
let span = input.span(); let span = input.span();
match input {
Value::String { val, .. } => { let parse_as_string = |val: &str| {
match dateformat { match dateformat {
Some(dt) => match DateTime::parse_from_str(val, &dt.0) { Some(dt) => match DateTime::parse_from_str(val, &dt.0) {
Ok(d) => Value::date ( d, head ), Ok(d) => Value::date ( d, head ),
@ -414,7 +414,12 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value {
Err(err) => err, Err(err) => err,
}, },
} }
} };
match input {
Value::String { val, .. } => parse_as_string(val),
Value::Int { val, .. } => parse_as_string(&val.to_string()),
// Propagate errors by explicitly matching them before the final case. // Propagate errors by explicitly matching them before the final case.
Value::Error { .. } => input.clone(), Value::Error { .. } => input.clone(),
other => Value::error( other => Value::error(