From 7c160725ede01b2f044b1821ad53be72d8ae7d77 Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Fri, 21 Mar 2025 13:36:21 -0400 Subject: [PATCH] Rename user-facing 'date' to 'datetime' (#15264) We only have one valid `datetime` type, but the string representation of that type was `date`. This PR updates the string representation of the `datetime` type to be `datetime` and updates other affected dependencies: * A `describe` example that used `date` * The style computer automatically recognized the new change, but also changed the default `date: purple` to `datetime: purple`. * Likewise, changed the `default_config.nu` to populate `$env.config.color_config.datetime` * Likewise, the dark and light themes in `std/config` * Updates tests * Unrelated, but changed the `into value` error messages to use *"datetime"* if there's an issue. Fixes #9916 and perhaps others. ## Breaking Changes: * Code that expected `describe` to return a `date` will now return a `datetime` * User configs and themes that override `$env.config.color_config.date` will need to be updated to use `datetime` --- crates/nu-cmd-lang/src/core_commands/describe.rs | 2 +- crates/nu-color-config/src/style_computer.rs | 2 +- crates/nu-command/src/conversions/into/value.rs | 6 +++--- crates/nu-command/tests/commands/table.rs | 8 ++++---- crates/nu-command/tests/format_conversions/nuon.rs | 2 +- crates/nu-protocol/src/ty.rs | 4 ++-- crates/nu-protocol/src/value/mod.rs | 2 +- crates/nu-std/std/config/mod.nu | 4 ++-- crates/nu-utils/src/default_files/default_config.nu | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/nu-cmd-lang/src/core_commands/describe.rs b/crates/nu-cmd-lang/src/core_commands/describe.rs index 375a840b16..b3f7b50611 100644 --- a/crates/nu-cmd-lang/src/core_commands/describe.rs +++ b/crates/nu-cmd-lang/src/core_commands/describe.rs @@ -103,7 +103,7 @@ impl Command for Describe { "category" => Value::test_string("default"), )), )), - "first_commit" => Value::test_string("date"), + "first_commit" => Value::test_string("datetime"), "my_duration" => Value::test_string("duration"), )), ))), diff --git a/crates/nu-color-config/src/style_computer.rs b/crates/nu-color-config/src/style_computer.rs index b055a6a46c..af467f31db 100644 --- a/crates/nu-color-config/src/style_computer.rs +++ b/crates/nu-color-config/src/style_computer.rs @@ -120,7 +120,7 @@ impl<'a> StyleComputer<'a> { ("int".to_string(), ComputableStyle::Static(Color::White.normal())), ("filesize".to_string(), ComputableStyle::Static(Color::Cyan.normal())), ("duration".to_string(), ComputableStyle::Static(Color::White.normal())), - ("date".to_string(), ComputableStyle::Static(Color::Purple.normal())), + ("datetime".to_string(), ComputableStyle::Static(Color::Purple.normal())), ("range".to_string(), ComputableStyle::Static(Color::White.normal())), ("float".to_string(), ComputableStyle::Static(Color::White.normal())), ("string".to_string(), ComputableStyle::Static(Color::White.normal())), diff --git a/crates/nu-command/src/conversions/into/value.rs b/crates/nu-command/src/conversions/into/value.rs index de371e27b9..eb2cf3a278 100644 --- a/crates/nu-command/src/conversions/into/value.rs +++ b/crates/nu-command/src/conversions/into/value.rs @@ -208,7 +208,7 @@ fn process_cell(val: Value, display_as_filesizes: bool, span: Span) -> Result Result Result String::from("closure"), Type::Bool => String::from("bool"), Type::CellPath => String::from("cell-path"), - Type::Date => String::from("date"), + Type::Date => String::from("datetime"), Type::Duration => String::from("duration"), Type::Filesize => String::from("filesize"), Type::Float => String::from("float"), @@ -162,7 +162,7 @@ impl Display for Type { Type::Closure => write!(f, "closure"), Type::Bool => write!(f, "bool"), Type::CellPath => write!(f, "cell-path"), - Type::Date => write!(f, "date"), + Type::Date => write!(f, "datetime"), Type::Duration => write!(f, "duration"), Type::Filesize => write!(f, "filesize"), Type::Float => write!(f, "float"), diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index 428031c48f..4969daf28e 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -329,7 +329,7 @@ impl Value { if let Value::Date { val, .. } = self { Ok(*val) } else { - self.cant_convert_to("date") + self.cant_convert_to("datetime") } } diff --git a/crates/nu-std/std/config/mod.nu b/crates/nu-std/std/config/mod.nu index 9b00db60db..ce4549d3be 100644 --- a/crates/nu-std/std/config/mod.nu +++ b/crates/nu-std/std/config/mod.nu @@ -13,7 +13,7 @@ export def dark-theme [] { int: white filesize: cyan duration: white - date: purple + datetime: purple range: white float: white string: white @@ -81,7 +81,7 @@ export def light-theme [] { int: dark_gray filesize: cyan_bold duration: dark_gray - date: purple + datetime: purple range: dark_gray float: dark_gray string: dark_gray diff --git a/crates/nu-utils/src/default_files/default_config.nu b/crates/nu-utils/src/default_files/default_config.nu index b7cc5675fc..40647d49b8 100644 --- a/crates/nu-utils/src/default_files/default_config.nu +++ b/crates/nu-utils/src/default_files/default_config.nu @@ -10,7 +10,7 @@ $env.config.color_config = { int: white filesize: cyan duration: white - date: purple + datetime: purple range: white float: white string: white