mirror of
https://github.com/nushell/nushell
synced 2024-12-25 12:33:17 +00: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
1 changed files with 15 additions and 9 deletions
|
@ -185,11 +185,13 @@ impl Command for SubCommand {
|
|||
example: "'16.11.1984 8:00 am' | into datetime --format '%d.%m.%Y %H:%M %P'",
|
||||
#[allow(clippy::inconsistent_digit_grouping)]
|
||||
result: Some(Value::date(
|
||||
DateTime::from_naive_utc_and_offset(
|
||||
NaiveDateTime::parse_from_str("16.11.1984 8:00 am", "%d.%m.%Y %H:%M %P")
|
||||
.expect("date calculation should not fail in test"),
|
||||
*Local::now().offset(),
|
||||
),
|
||||
Local
|
||||
.from_local_datetime(
|
||||
&NaiveDateTime::parse_from_str("16.11.1984 8:00 am", "%d.%m.%Y %H:%M %P")
|
||||
.expect("date calculation should not fail in test"),
|
||||
)
|
||||
.unwrap()
|
||||
.with_timezone(Local::now().offset()),
|
||||
Span::test_data(),
|
||||
)),
|
||||
},
|
||||
|
@ -524,12 +526,16 @@ mod tests {
|
|||
};
|
||||
let actual = action(&date_str, &args, Span::test_data());
|
||||
let expected = Value::date(
|
||||
DateTime::from_naive_utc_and_offset(
|
||||
NaiveDateTime::parse_from_str("16.11.1984 8:00 am", "%d.%m.%Y %H:%M %P").unwrap(),
|
||||
*Local::now().offset(),
|
||||
),
|
||||
Local
|
||||
.from_local_datetime(
|
||||
&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(),
|
||||
);
|
||||
|
||||
assert_eq!(actual, expected)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue