mirror of
https://github.com/nushell/nushell.git
synced 2025-08-16 20:11:50 +02:00
Deprecate date to-record
and date to-table
This commit is contained in:
@ -99,6 +99,22 @@ impl Command for SubCommand {
|
||||
"timezone" => Value::test_string("+02:00"),
|
||||
})),
|
||||
},
|
||||
Example {
|
||||
description: "convert date components to table columns",
|
||||
example: "2020-04-12T22:10:57+02:00 | into record | transpose | transpose -r",
|
||||
result: Some(Value::test_list(vec![Value::test_record(record! {
|
||||
"year" => Value::test_int(2020),
|
||||
"month" => Value::test_int(4),
|
||||
"day" => Value::test_int(12),
|
||||
"hour" => Value::test_int(22),
|
||||
"minute" => Value::test_int(10),
|
||||
"second" => Value::test_int(57),
|
||||
"millisecond" => Value::test_int(0),
|
||||
"microsecond" => Value::test_int(0),
|
||||
"nanosecond" => Value::test_int(0),
|
||||
"timezone" => Value::test_string("+02:00"),
|
||||
})])),
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::date::utils::parse_date_from_string;
|
||||
use chrono::{DateTime, Datelike, FixedOffset, Local, Timelike};
|
||||
use nu_engine::command_prelude::*;
|
||||
use nu_protocol::{report_parse_warning, ParseWarning};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
@ -35,6 +36,18 @@ impl Command for SubCommand {
|
||||
call: &Call,
|
||||
input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
|
||||
let head = call.head;
|
||||
report_parse_warning(
|
||||
&StateWorkingSet::new(&engine_state),
|
||||
&ParseWarning::DeprecatedWarning {
|
||||
old_command: "date to-record".into(),
|
||||
new_suggestion: "see `into record` command examples".into(),
|
||||
span: head,
|
||||
url: "`help into record`".into(),
|
||||
},
|
||||
);
|
||||
|
||||
let head = call.head;
|
||||
// This doesn't match explicit nulls
|
||||
if matches!(input, PipelineData::Empty) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::date::utils::parse_date_from_string;
|
||||
use chrono::{DateTime, Datelike, FixedOffset, Local, Timelike};
|
||||
use nu_engine::command_prelude::*;
|
||||
use nu_protocol::{report_parse_warning, ParseWarning};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
@ -36,6 +37,16 @@ impl Command for SubCommand {
|
||||
input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
let head = call.head;
|
||||
report_parse_warning(
|
||||
&StateWorkingSet::new(&engine_state),
|
||||
&ParseWarning::DeprecatedWarning {
|
||||
old_command: "date to-table".into(),
|
||||
new_suggestion: "see `into record` command examples".into(),
|
||||
span: head,
|
||||
url: "`help into record`".into(),
|
||||
},
|
||||
);
|
||||
|
||||
// This doesn't match explicit nulls
|
||||
if matches!(input, PipelineData::Empty) {
|
||||
return Err(ShellError::PipelineEmpty { dst_span: head });
|
||||
|
@ -120,8 +120,8 @@ export def datetime-diff [
|
||||
}
|
||||
}
|
||||
}
|
||||
let from_expanded = ($later | date to-timezone utc | date to-record)
|
||||
let to_expanded = ($earlier | date to-timezone utc | date to-record)
|
||||
let from_expanded = ($later | date to-timezone utc | into record)
|
||||
let to_expanded = ($earlier | date to-timezone utc | into record)
|
||||
|
||||
mut result = { year: ($from_expanded.year - $to_expanded.year), month: ($from_expanded.month - $to_expanded.month), day:0, hour:0, minute:0, second:0, millisecond:0, microsecond:0, nanosecond:0}
|
||||
|
||||
|
Reference in New Issue
Block a user