Skip to content

Commit

Permalink
Adjust examples in date commands (#12055)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
robjwells committed Mar 3, 2024
1 parent 3ee2fc6 commit 71aacf5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion crates/nu-command/src/date/list_timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Command for SubCommand {
fn examples(&self) -> Vec<Example> {
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"),
})])),
Expand Down
6 changes: 3 additions & 3 deletions crates/nu-command/src/date/now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
5 changes: 0 additions & 5 deletions crates/nu-command/src/date/to_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ impl Command for SubCommand {

fn examples(&self) -> Vec<Example> {
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",
Expand Down
5 changes: 0 additions & 5 deletions crates/nu-command/src/date/to_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
10 changes: 5 additions & 5 deletions crates/nu-command/src/date/to_timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand Down

0 comments on commit 71aacf5

Please sign in to comment.