Skip to content

Commit 7c16072

Browse files
authored
Rename user-facing 'date' to 'datetime' (nushell#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 nushell#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`
1 parent 5832823 commit 7c16072

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

crates/nu-cmd-lang/src/core_commands/describe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Command for Describe {
103103
"category" => Value::test_string("default"),
104104
)),
105105
)),
106-
"first_commit" => Value::test_string("date"),
106+
"first_commit" => Value::test_string("datetime"),
107107
"my_duration" => Value::test_string("duration"),
108108
)),
109109
))),

crates/nu-color-config/src/style_computer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'a> StyleComputer<'a> {
120120
("int".to_string(), ComputableStyle::Static(Color::White.normal())),
121121
("filesize".to_string(), ComputableStyle::Static(Color::Cyan.normal())),
122122
("duration".to_string(), ComputableStyle::Static(Color::White.normal())),
123-
("date".to_string(), ComputableStyle::Static(Color::Purple.normal())),
123+
("datetime".to_string(), ComputableStyle::Static(Color::Purple.normal())),
124124
("range".to_string(), ComputableStyle::Static(Color::White.normal())),
125125
("float".to_string(), ComputableStyle::Static(Color::White.normal())),
126126
("string".to_string(), ComputableStyle::Static(Color::White.normal())),

crates/nu-command/src/conversions/into/value.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ fn process_cell(val: Value, display_as_filesizes: bool, span: Span) -> Result<Va
208208
}
209209
} else if DATETIME_DMY_RE.is_match(&val_str).unwrap_or(false) {
210210
let dt = parse_date_from_string(&val_str, span).map_err(|_| ShellError::CantConvert {
211-
to_type: "date".to_string(),
211+
to_type: "datetime".to_string(),
212212
from_type: "string".to_string(),
213213
span,
214214
help: Some(format!(
@@ -219,7 +219,7 @@ fn process_cell(val: Value, display_as_filesizes: bool, span: Span) -> Result<Va
219219
Ok(Value::date(dt, span))
220220
} else if DATETIME_YMD_RE.is_match(&val_str).unwrap_or(false) {
221221
let dt = parse_date_from_string(&val_str, span).map_err(|_| ShellError::CantConvert {
222-
to_type: "date".to_string(),
222+
to_type: "datetime".to_string(),
223223
from_type: "string".to_string(),
224224
span,
225225
help: Some(format!(
@@ -230,7 +230,7 @@ fn process_cell(val: Value, display_as_filesizes: bool, span: Span) -> Result<Va
230230
Ok(Value::date(dt, span))
231231
} else if DATETIME_YMDZ_RE.is_match(&val_str).unwrap_or(false) {
232232
let dt = parse_date_from_string(&val_str, span).map_err(|_| ShellError::CantConvert {
233-
to_type: "date".to_string(),
233+
to_type: "datetime".to_string(),
234234
from_type: "string".to_string(),
235235
span,
236236
help: Some(format!(

crates/nu-command/tests/commands/table.rs

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

crates/nu-command/tests/format_conversions/nuon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ fn from_nuon_datetime() {
303303
"#
304304
));
305305

306-
assert_eq!(actual.out, "date");
306+
assert_eq!(actual.out, "datetime");
307307
}
308308

309309
#[test]

crates/nu-protocol/src/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl Type {
135135
Type::Closure => String::from("closure"),
136136
Type::Bool => String::from("bool"),
137137
Type::CellPath => String::from("cell-path"),
138-
Type::Date => String::from("date"),
138+
Type::Date => String::from("datetime"),
139139
Type::Duration => String::from("duration"),
140140
Type::Filesize => String::from("filesize"),
141141
Type::Float => String::from("float"),
@@ -162,7 +162,7 @@ impl Display for Type {
162162
Type::Closure => write!(f, "closure"),
163163
Type::Bool => write!(f, "bool"),
164164
Type::CellPath => write!(f, "cell-path"),
165-
Type::Date => write!(f, "date"),
165+
Type::Date => write!(f, "datetime"),
166166
Type::Duration => write!(f, "duration"),
167167
Type::Filesize => write!(f, "filesize"),
168168
Type::Float => write!(f, "float"),

crates/nu-protocol/src/value/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl Value {
329329
if let Value::Date { val, .. } = self {
330330
Ok(*val)
331331
} else {
332-
self.cant_convert_to("date")
332+
self.cant_convert_to("datetime")
333333
}
334334
}
335335

crates/nu-std/std/config/mod.nu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export def dark-theme [] {
1313
int: white
1414
filesize: cyan
1515
duration: white
16-
date: purple
16+
datetime: purple
1717
range: white
1818
float: white
1919
string: white
@@ -81,7 +81,7 @@ export def light-theme [] {
8181
int: dark_gray
8282
filesize: cyan_bold
8383
duration: dark_gray
84-
date: purple
84+
datetime: purple
8585
range: dark_gray
8686
float: dark_gray
8787
string: dark_gray

crates/nu-utils/src/default_files/default_config.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $env.config.color_config = {
1010
int: white
1111
filesize: cyan
1212
duration: white
13-
date: purple
13+
datetime: purple
1414
range: white
1515
float: white
1616
string: white

0 commit comments

Comments
 (0)