Enable converting dates to ints (#5489)

This commit is contained in:
Reilly Wood 2022-05-10 11:15:28 -07:00 committed by GitHub
parent 75c033e4d1
commit c0b99b7131
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -85,6 +85,11 @@ impl Command for SubCommand {
span: Span::test_data(),
}),
},
Example {
description: "Convert date to integer (Unix timestamp)",
example: "2022-02-02 | into int",
result: Some(Value::test_int(1643760000)),
},
Example {
description: "Convert to integer from binary",
example: "'1101' | into int -r 2",
@ -181,6 +186,10 @@ pub fn action(input: &Value, span: Span, radix: u32) -> Value {
Value::Int { val: 0, span }
}
}
Value::Date { val, .. } => Value::Int {
val: val.timestamp(),
span,
},
_ => Value::Error {
error: ShellError::UnsupportedInput("'into int' for unsupported type".into(), span),
},