mirror of
https://github.com/nushell/nushell.git
synced 2024-11-24 17:34:00 +01:00
Fix ignored into datetime
test (#14302)
# Description Fixes test which was ignored in #14297. Also fixes related example. Tests now use local timezone to match actual result. More discussion in #14266 # User-Facing Changes Tests-only # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
This commit is contained in:
parent
55db643048
commit
07ad24ab97
@ -185,11 +185,13 @@ impl Command for SubCommand {
|
|||||||
example: "'16.11.1984 8:00 am' | into datetime --format '%d.%m.%Y %H:%M %P'",
|
example: "'16.11.1984 8:00 am' | into datetime --format '%d.%m.%Y %H:%M %P'",
|
||||||
#[allow(clippy::inconsistent_digit_grouping)]
|
#[allow(clippy::inconsistent_digit_grouping)]
|
||||||
result: Some(Value::date(
|
result: Some(Value::date(
|
||||||
DateTime::from_naive_utc_and_offset(
|
Local
|
||||||
NaiveDateTime::parse_from_str("16.11.1984 8:00 am", "%d.%m.%Y %H:%M %P")
|
.from_local_datetime(
|
||||||
.expect("date calculation should not fail in test"),
|
&NaiveDateTime::parse_from_str("16.11.1984 8:00 am", "%d.%m.%Y %H:%M %P")
|
||||||
*Local::now().offset(),
|
.expect("date calculation should not fail in test"),
|
||||||
),
|
)
|
||||||
|
.unwrap()
|
||||||
|
.with_timezone(Local::now().offset()),
|
||||||
Span::test_data(),
|
Span::test_data(),
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
@ -524,12 +526,16 @@ mod tests {
|
|||||||
};
|
};
|
||||||
let actual = action(&date_str, &args, Span::test_data());
|
let actual = action(&date_str, &args, Span::test_data());
|
||||||
let expected = Value::date(
|
let expected = Value::date(
|
||||||
DateTime::from_naive_utc_and_offset(
|
Local
|
||||||
NaiveDateTime::parse_from_str("16.11.1984 8:00 am", "%d.%m.%Y %H:%M %P").unwrap(),
|
.from_local_datetime(
|
||||||
*Local::now().offset(),
|
&NaiveDateTime::parse_from_str("16.11.1984 8:00 am", "%d.%m.%Y %H:%M %P")
|
||||||
),
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
.with_timezone(Local::now().offset()),
|
||||||
Span::test_data(),
|
Span::test_data(),
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(actual, expected)
|
assert_eq!(actual, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user