From e5621dea58dbd63f1a42381573d80ba58ffa2171 Mon Sep 17 00:00:00 2001 From: Mohammed Anas <6daf084a-8eaf-40fb-86c7-8500077c3b69@anonaddy.me> Date: Sun, 4 Apr 2021 18:19:33 +0000 Subject: [PATCH] Remove `yr` and `mon` (#3262) * Remove `yr` and `mon` * Remove usage of mon in test * Fix test --- crates/nu-command/src/commands/where_.rs | 4 +-- crates/nu-command/tests/commands/math/mod.rs | 4 +-- .../tests/format_conversions/html.rs | 2 +- crates/nu-parser/src/parse.rs | 2 -- crates/nu-protocol/src/hir.rs | 26 ------------------- tests/shell/pipeline/commands/internal.rs | 4 +-- 6 files changed, 7 insertions(+), 35 deletions(-) diff --git a/crates/nu-command/src/commands/where_.rs b/crates/nu-command/src/commands/where_.rs index e078a5a995..a8f9bc707f 100644 --- a/crates/nu-command/src/commands/where_.rs +++ b/crates/nu-command/src/commands/where_.rs @@ -53,8 +53,8 @@ impl WholeStreamCommand for Command { result: None, }, Example { - description: "List all files that were modified in the last two months", - example: "ls | where modified <= 2mon", + description: "List all files that were modified in the last two weeks", + example: "ls | where modified <= 2wk", result: None, }, ] diff --git a/crates/nu-command/tests/commands/math/mod.rs b/crates/nu-command/tests/commands/math/mod.rs index f49a6a8e59..6a034b564a 100644 --- a/crates/nu-command/tests/commands/math/mod.rs +++ b/crates/nu-command/tests/commands/math/mod.rs @@ -192,11 +192,11 @@ fn duration_decimal_math() { let actual = nu!( cwd: "tests/fixtures/formats", pipeline( r#" - = 0.5mon + 1day + = 5.5day + 0.5day "# )); - assert_eq!(actual.out, "16day"); + assert_eq!(actual.out, "6day"); } #[test] diff --git a/crates/nu-command/tests/format_conversions/html.rs b/crates/nu-command/tests/format_conversions/html.rs index 42311ffdc1..36ebfff4a3 100644 --- a/crates/nu-command/tests/format_conversions/html.rs +++ b/crates/nu-command/tests/format_conversions/html.rs @@ -86,6 +86,6 @@ fn test_html_color_where_flag_dark_false() { ); assert_eq!( actual.out, - r"Filter table to match the condition.

Usage:
> where <condition> {flags}

Parameters:
<condition> the condition that must match

Flags:
-h, --help: Display this help message

Examples:
List all files in the current directory with sizes greater than 2kb
> ls | where size > 2kb

List only the files in the current directory
>
ls
| where type == File

List all files with names that contain "Car"
>
ls
| where name =~ "Car"

List all files that were modified in the last two months
>
ls
| where modified <= 2mon

" + r"Filter table to match the condition.

Usage:
> where <condition> {flags}

Parameters:
<condition> the condition that must match

Flags:
-h, --help: Display this help message

Examples:
List all files in the current directory with sizes greater than 2kb
> ls | where size > 2kb

List only the files in the current directory
>
ls
| where type == File

List all files with names that contain "Car"
>
ls
| where name =~ "Car"

List all files that were modified in the last two weeks
>
ls
| where modified <= 2wk

" ); } diff --git a/crates/nu-parser/src/parse.rs b/crates/nu-parser/src/parse.rs index 7a2f7667e6..127ca8c557 100644 --- a/crates/nu-parser/src/parse.rs +++ b/crates/nu-parser/src/parse.rs @@ -352,8 +352,6 @@ fn parse_unit(lite_arg: &Spanned) -> (SpannedExpression, Option "hr", Unit::Day => "day", Unit::Week => "wk", - Unit::Month => "mon", - Unit::Year => "yr", } } @@ -624,28 +620,6 @@ impl Unit { * 1000 * 1000, ), - // FIXME: Number of days per month should not always be 30. - Unit::Month => duration( - size.to_bigint().expect("Conversion should never fail.") - * 30 - * 24 - * 60 - * 60 - * 1000 - * 1000 - * 1000, - ), - // FIXME: Number of days per year should not be 365. - Unit::Year => duration( - size.to_bigint().expect("Conversion should never fail.") - * 365 - * 24 - * 60 - * 60 - * 1000 - * 1000 - * 1000, - ), } } } diff --git a/tests/shell/pipeline/commands/internal.rs b/tests/shell/pipeline/commands/internal.rs index 28648af881..61f8b60189 100644 --- a/tests/shell/pipeline/commands/internal.rs +++ b/tests/shell/pipeline/commands/internal.rs @@ -678,7 +678,7 @@ fn duration_overflow() { let actual = nu!( cwd: ".", pipeline( r#" - ls | get modified | each { = $it + 1000000000000000000yr } + ls | get modified | each { = $it + 10000000000000000day } "#) ); @@ -690,7 +690,7 @@ fn date_and_duration_overflow() { let actual = nu!( cwd: ".", pipeline( r#" - ls | get modified | each { = $it + 1000000yr } + ls | get modified | each { = $it + 1000000000day } "#) );