mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Enable converting dates to ints (#5489)
This commit is contained in:
parent
75c033e4d1
commit
c0b99b7131
1 changed files with 9 additions and 0 deletions
|
@ -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),
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue