From 71aacf50321cb1c5af5fa402e472762f21211c21 Mon Sep 17 00:00:00 2001 From: Rob Wells Date: Sun, 3 Mar 2024 21:10:50 +0000 Subject: [PATCH] Adjust examples in date commands (#12055) Hello! This is my first PR to nushell, as I was looking at things for #5066. The usage text for the date commands seemed fine to me, so this is just a bit of a tidy up of the examples, mostly the description text. # Description - Remove two incorrect examples for `date to-record` and `date to-table` where nothing was piped in (which causes an error in actual use). - Fix misleading descriptions in `date to-timezone` which erroneously referred to Hawaii's time zone. - Standardise on "time zone" in written descriptions. - Generally tidy up example descriptions and improve consistency. # User-Facing Changes Only in related help text showing examples. --- crates/nu-command/src/date/list_timezone.rs | 2 +- crates/nu-command/src/date/now.rs | 6 +++--- crates/nu-command/src/date/to_record.rs | 5 ----- crates/nu-command/src/date/to_table.rs | 5 ----- crates/nu-command/src/date/to_timezone.rs | 10 +++++----- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/crates/nu-command/src/date/list_timezone.rs b/crates/nu-command/src/date/list_timezone.rs index 9d8470b5b0..e0399564a3 100644 --- a/crates/nu-command/src/date/list_timezone.rs +++ b/crates/nu-command/src/date/list_timezone.rs @@ -51,7 +51,7 @@ impl Command for SubCommand { fn examples(&self) -> Vec { vec![Example { example: "date list-timezone | where timezone =~ Shanghai", - description: "Show timezone(s) that contains 'Shanghai'", + description: "Show time zone(s) that contains 'Shanghai'", result: Some(Value::test_list(vec![Value::test_record(record! { "timezone" => Value::test_string("Asia/Shanghai"), })])), diff --git a/crates/nu-command/src/date/now.rs b/crates/nu-command/src/date/now.rs index 4a655a8464..ddd5c71aa1 100644 --- a/crates/nu-command/src/date/now.rs +++ b/crates/nu-command/src/date/now.rs @@ -46,17 +46,17 @@ impl Command for SubCommand { result: None, }, Example { - description: "Get the time duration from 2019-04-30 to now", + description: "Get the time duration since 2019-04-30.", example: r#"(date now) - 2019-05-01"#, result: None, }, Example { - description: "Get the time duration since a more accurate time", + description: "Get the time duration since a more specific time.", example: r#"(date now) - 2019-05-01T04:12:05.20+08:00"#, result: None, }, Example { - description: "Get current time in full RFC3339 format with timezone", + description: "Get current time in full RFC 3339 format with time zone.", example: r#"date now | debug"#, result: None, }, diff --git a/crates/nu-command/src/date/to_record.rs b/crates/nu-command/src/date/to_record.rs index 31b2cf138e..589bb2d621 100644 --- a/crates/nu-command/src/date/to_record.rs +++ b/crates/nu-command/src/date/to_record.rs @@ -50,11 +50,6 @@ impl Command for SubCommand { fn examples(&self) -> Vec { vec![ - Example { - description: "Convert the current date into a record.", - example: "date to-record", - result: None, - }, Example { description: "Convert the current date into a record.", example: "date now | date to-record", diff --git a/crates/nu-command/src/date/to_table.rs b/crates/nu-command/src/date/to_table.rs index 1a0930c021..8688d29810 100644 --- a/crates/nu-command/src/date/to_table.rs +++ b/crates/nu-command/src/date/to_table.rs @@ -52,11 +52,6 @@ impl Command for SubCommand { vec![ Example { description: "Convert the current date into a table.", - example: "date to-table", - result: None, - }, - Example { - description: "Convert the date into a table.", example: "date now | date to-table", result: None, }, diff --git a/crates/nu-command/src/date/to_timezone.rs b/crates/nu-command/src/date/to_timezone.rs index b5886ea488..035bd4f702 100644 --- a/crates/nu-command/src/date/to_timezone.rs +++ b/crates/nu-command/src/date/to_timezone.rs @@ -77,27 +77,27 @@ impl Command for SubCommand { vec![ Example { - description: "Get the current date in UTC+05:00", + description: "Get the current date in UTC+05:00.", example: "date now | date to-timezone '+0500'", result: None, }, Example { - description: "Get the current local date", + description: "Get the current date in the local time zone.", example: "date now | date to-timezone local", result: None, }, Example { - description: "Get the current date in Hawaii", + description: "Get the current date in Hawaii.", example: "date now | date to-timezone US/Hawaii", result: None, }, Example { - description: "Get the current date in Hawaii", + description: "Get a date in a different time zone, from a string.", example: r#""2020-10-10 10:00:00 +02:00" | date to-timezone "+0500""#, result: example_result_1(), }, Example { - description: "Get the current date in Hawaii, from a datetime object", + description: "Get a date in a different time zone, from a datetime.", example: r#""2020-10-10 10:00:00 +02:00" | into datetime | date to-timezone "+0500""#, result: example_result_1(), },