mirror of
https://github.com/nushell/nushell.git
synced 2024-12-24 07:59:21 +01:00
5af8d62666
# Description fixed #12699 When bare dates or naive times are specified in toml files, `from toml` returns invalid dates or times. This PR fixes the problem to correctly handle toml datetime. The current version command returns the default datetime (`chrono::DateTime::default()`) if the datetime parse fails. However, I felt that this behavior was a bit unfriendly, so I changed it to return `Value::string`. # User-Facing Changes The command returns a date with default time and timezone if a bare date is specified. ``` ~/Development/nushell> "dob = 2023-05-27" | from toml ╭─────┬────────────╮ │ dob │ a year ago │ ╰─────┴────────────╯ ~/Development/nushell> "dob = 2023-05-27" | from toml | Sat, 27 May 2023 00:00:00 +0000 (a year ago) ~/Development/nushell> ``` If a bare time is given, a time string is returned. ``` ~/Development/nushell> "tm = 11:00:00" | from toml ╭────┬──────────╮ │ tm │ 11:00:00 │ ╰────┴──────────╯ ~/Development/nushell> "tm = 11:00:00" | from toml | get tm 11:00:00 ~/Development/nushell> ``` # Tests + Formatting When I ran tests, `commands::touch::change_file_mtime_to_reference` failed with the following error. The error also occurs in the master branch, so it's probably unrelated to these changes. (maybe a problem with my dev environment) ``` $ ~/Development/nushell> toolkit check pr ~~~~~~~~ test usage_start_uppercase ... ok test format_conversions::yaml::convert_dict_to_yaml_with_integer_floats_key ... ok test format_conversions::yaml::convert_dict_to_yaml_with_boolean_key ... ok test format_conversions::yaml::table_to_yaml_text_and_from_yaml_text_back_into_table ... ok test quickcheck_parse ... ok test format_conversions::yaml::convert_dict_to_yaml_with_integer_key ... ok failures: ---- commands::touch::change_file_mtime_to_reference stdout ---- === stderr thread 'commands::touch::change_file_mtime_to_reference' panicked at crates/nu-command/tests/commands/touch.rs:298:9: assertion `left == right` failed left: SystemTime { tv_sec: 1720344745, tv_nsec: 862392750 } right: SystemTime { tv_sec: 1720344745, tv_nsec: 887670417 } failures: commands::touch::change_file_mtime_to_reference test result: FAILED. 1542 passed; 1 failed; 32 ignored; 0 measured; 0 filtered out; finished in 12.04s error: test failed, to rerun pass `-p nu-command --test main` - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🔴 `toolkit test` - ⚫ `toolkit test stdlib` ~/Development/nushell> toolkit test stdlib Compiling nu v0.95.1 (/Users/hiroki/Development/nushell) Compiling nu-cmd-lang v0.95.1 (/Users/hiroki/Development/nushell/crates/nu-cmd-lang) Finished dev [unoptimized + debuginfo] target(s) in 6.64s Running `target/debug/nu --no-config-file -c ' use crates/nu-std/testing.nu testing run-tests --path crates/nu-std '` 2024-07-07T19:00:20.423|INF|Running from_jsonl_invalid_object in module test_formats 2024-07-07T19:00:20.436|INF|Running env_log-prefix in module test_logger_env ~~~~~~~~~~~ 2024-07-07T19:00:22.196|INF|Running debug_short in module test_basic_commands ~/Development/nushell> ``` # After Submitting nothing |
||
---|---|---|
.. | ||
src | ||
tests | ||
Cargo.toml | ||
LICENSE |