mirror of
https://github.com/nushell/nushell.git
synced 2025-03-30 01:28:11 +01:00
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`
This commit is contained in:
parent
5832823dff
commit
7c160725ed
@ -103,7 +103,7 @@ impl Command for Describe {
|
|||||||
"category" => Value::test_string("default"),
|
"category" => Value::test_string("default"),
|
||||||
)),
|
)),
|
||||||
)),
|
)),
|
||||||
"first_commit" => Value::test_string("date"),
|
"first_commit" => Value::test_string("datetime"),
|
||||||
"my_duration" => Value::test_string("duration"),
|
"my_duration" => Value::test_string("duration"),
|
||||||
)),
|
)),
|
||||||
))),
|
))),
|
||||||
|
@ -120,7 +120,7 @@ impl<'a> StyleComputer<'a> {
|
|||||||
("int".to_string(), ComputableStyle::Static(Color::White.normal())),
|
("int".to_string(), ComputableStyle::Static(Color::White.normal())),
|
||||||
("filesize".to_string(), ComputableStyle::Static(Color::Cyan.normal())),
|
("filesize".to_string(), ComputableStyle::Static(Color::Cyan.normal())),
|
||||||
("duration".to_string(), ComputableStyle::Static(Color::White.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())),
|
("range".to_string(), ComputableStyle::Static(Color::White.normal())),
|
||||||
("float".to_string(), ComputableStyle::Static(Color::White.normal())),
|
("float".to_string(), ComputableStyle::Static(Color::White.normal())),
|
||||||
("string".to_string(), ComputableStyle::Static(Color::White.normal())),
|
("string".to_string(), ComputableStyle::Static(Color::White.normal())),
|
||||||
|
@ -208,7 +208,7 @@ fn process_cell(val: Value, display_as_filesizes: bool, span: Span) -> Result<Va
|
|||||||
}
|
}
|
||||||
} else if DATETIME_DMY_RE.is_match(&val_str).unwrap_or(false) {
|
} else if DATETIME_DMY_RE.is_match(&val_str).unwrap_or(false) {
|
||||||
let dt = parse_date_from_string(&val_str, span).map_err(|_| ShellError::CantConvert {
|
let dt = parse_date_from_string(&val_str, span).map_err(|_| ShellError::CantConvert {
|
||||||
to_type: "date".to_string(),
|
to_type: "datetime".to_string(),
|
||||||
from_type: "string".to_string(),
|
from_type: "string".to_string(),
|
||||||
span,
|
span,
|
||||||
help: Some(format!(
|
help: Some(format!(
|
||||||
@ -219,7 +219,7 @@ fn process_cell(val: Value, display_as_filesizes: bool, span: Span) -> Result<Va
|
|||||||
Ok(Value::date(dt, span))
|
Ok(Value::date(dt, span))
|
||||||
} else if DATETIME_YMD_RE.is_match(&val_str).unwrap_or(false) {
|
} else if DATETIME_YMD_RE.is_match(&val_str).unwrap_or(false) {
|
||||||
let dt = parse_date_from_string(&val_str, span).map_err(|_| ShellError::CantConvert {
|
let dt = parse_date_from_string(&val_str, span).map_err(|_| ShellError::CantConvert {
|
||||||
to_type: "date".to_string(),
|
to_type: "datetime".to_string(),
|
||||||
from_type: "string".to_string(),
|
from_type: "string".to_string(),
|
||||||
span,
|
span,
|
||||||
help: Some(format!(
|
help: Some(format!(
|
||||||
@ -230,7 +230,7 @@ fn process_cell(val: Value, display_as_filesizes: bool, span: Span) -> Result<Va
|
|||||||
Ok(Value::date(dt, span))
|
Ok(Value::date(dt, span))
|
||||||
} else if DATETIME_YMDZ_RE.is_match(&val_str).unwrap_or(false) {
|
} else if DATETIME_YMDZ_RE.is_match(&val_str).unwrap_or(false) {
|
||||||
let dt = parse_date_from_string(&val_str, span).map_err(|_| ShellError::CantConvert {
|
let dt = parse_date_from_string(&val_str, span).map_err(|_| ShellError::CantConvert {
|
||||||
to_type: "date".to_string(),
|
to_type: "datetime".to_string(),
|
||||||
from_type: "string".to_string(),
|
from_type: "string".to_string(),
|
||||||
span,
|
span,
|
||||||
help: Some(format!(
|
help: Some(format!(
|
||||||
|
File diff suppressed because one or more lines are too long
@ -303,7 +303,7 @@ fn from_nuon_datetime() {
|
|||||||
"#
|
"#
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(actual.out, "date");
|
assert_eq!(actual.out, "datetime");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -135,7 +135,7 @@ impl Type {
|
|||||||
Type::Closure => String::from("closure"),
|
Type::Closure => String::from("closure"),
|
||||||
Type::Bool => String::from("bool"),
|
Type::Bool => String::from("bool"),
|
||||||
Type::CellPath => String::from("cell-path"),
|
Type::CellPath => String::from("cell-path"),
|
||||||
Type::Date => String::from("date"),
|
Type::Date => String::from("datetime"),
|
||||||
Type::Duration => String::from("duration"),
|
Type::Duration => String::from("duration"),
|
||||||
Type::Filesize => String::from("filesize"),
|
Type::Filesize => String::from("filesize"),
|
||||||
Type::Float => String::from("float"),
|
Type::Float => String::from("float"),
|
||||||
@ -162,7 +162,7 @@ impl Display for Type {
|
|||||||
Type::Closure => write!(f, "closure"),
|
Type::Closure => write!(f, "closure"),
|
||||||
Type::Bool => write!(f, "bool"),
|
Type::Bool => write!(f, "bool"),
|
||||||
Type::CellPath => write!(f, "cell-path"),
|
Type::CellPath => write!(f, "cell-path"),
|
||||||
Type::Date => write!(f, "date"),
|
Type::Date => write!(f, "datetime"),
|
||||||
Type::Duration => write!(f, "duration"),
|
Type::Duration => write!(f, "duration"),
|
||||||
Type::Filesize => write!(f, "filesize"),
|
Type::Filesize => write!(f, "filesize"),
|
||||||
Type::Float => write!(f, "float"),
|
Type::Float => write!(f, "float"),
|
||||||
|
@ -329,7 +329,7 @@ impl Value {
|
|||||||
if let Value::Date { val, .. } = self {
|
if let Value::Date { val, .. } = self {
|
||||||
Ok(*val)
|
Ok(*val)
|
||||||
} else {
|
} else {
|
||||||
self.cant_convert_to("date")
|
self.cant_convert_to("datetime")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export def dark-theme [] {
|
|||||||
int: white
|
int: white
|
||||||
filesize: cyan
|
filesize: cyan
|
||||||
duration: white
|
duration: white
|
||||||
date: purple
|
datetime: purple
|
||||||
range: white
|
range: white
|
||||||
float: white
|
float: white
|
||||||
string: white
|
string: white
|
||||||
@ -81,7 +81,7 @@ export def light-theme [] {
|
|||||||
int: dark_gray
|
int: dark_gray
|
||||||
filesize: cyan_bold
|
filesize: cyan_bold
|
||||||
duration: dark_gray
|
duration: dark_gray
|
||||||
date: purple
|
datetime: purple
|
||||||
range: dark_gray
|
range: dark_gray
|
||||||
float: dark_gray
|
float: dark_gray
|
||||||
string: dark_gray
|
string: dark_gray
|
||||||
|
@ -10,7 +10,7 @@ $env.config.color_config = {
|
|||||||
int: white
|
int: white
|
||||||
filesize: cyan
|
filesize: cyan
|
||||||
duration: white
|
duration: white
|
||||||
date: purple
|
datetime: purple
|
||||||
range: white
|
range: white
|
||||||
float: white
|
float: white
|
||||||
string: white
|
string: white
|
||||||
|
Loading…
Reference in New Issue
Block a user