From 79359598db68fa0fff9daeb429c70cd89f4ee76a Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Sun, 23 Jul 2023 20:14:51 +0200 Subject: [PATCH] add `table -> table` to `into datetime` (#9775) should close https://github.com/nushell/nushell/issues/9774 # Description given the help page of `into datetime`, ``` Parameters: ...rest : for a data structure input, convert data at the given cell paths ``` it looks like `into datetime` should accept tables as input :thinking: this PR - adds the `table -> table` signature to `into datetime` - adds a test to make sure the behaviour stays there --- crates/nu-command/src/conversions/into/datetime.rs | 2 ++ crates/nu-command/tests/commands/into_datetime.rs | 8 ++++++++ crates/nu-command/tests/commands/mod.rs | 1 + 3 files changed, 11 insertions(+) create mode 100644 crates/nu-command/tests/commands/into_datetime.rs diff --git a/crates/nu-command/src/conversions/into/datetime.rs b/crates/nu-command/src/conversions/into/datetime.rs index 1a524cd81d..c826258df6 100644 --- a/crates/nu-command/src/conversions/into/datetime.rs +++ b/crates/nu-command/src/conversions/into/datetime.rs @@ -68,7 +68,9 @@ impl Command for SubCommand { (Type::Int, Type::Date), (Type::String, Type::Date), (Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Date))), + (Type::Table(vec![]), Type::Table(vec![])), ]) + .allow_variants_without_examples(true) .named( "timezone", SyntaxShape::String, diff --git a/crates/nu-command/tests/commands/into_datetime.rs b/crates/nu-command/tests/commands/into_datetime.rs new file mode 100644 index 0000000000..b741413e20 --- /dev/null +++ b/crates/nu-command/tests/commands/into_datetime.rs @@ -0,0 +1,8 @@ +use nu_test_support::nu; + +#[test] +fn into_datetime_table_column() { + let actual = nu!(r#"[[date]; ["2022-01-01"] ["2023-01-01"]] | into datetime date"#); + + assert!(actual.out.contains(" ago")); +} diff --git a/crates/nu-command/tests/commands/mod.rs b/crates/nu-command/tests/commands/mod.rs index 90d8cf21c1..7fb76f0f21 100644 --- a/crates/nu-command/tests/commands/mod.rs +++ b/crates/nu-command/tests/commands/mod.rs @@ -39,6 +39,7 @@ mod help; mod histogram; mod insert; mod inspect; +mod into_datetime; mod into_filesize; mod into_int; mod join;