Fix 8244 -- store timestamps with nanosecond resolution (consistently)#8337
Fix 8244 -- store timestamps with nanosecond resolution (consistently)#8337fdncred merged 7 commits intonushell:mainfrom
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8337 +/- ##
==========================================
- Coverage 68.56% 68.20% -0.37%
==========================================
Files 620 620
Lines 99304 99291 -13
==========================================
- Hits 68086 67719 -367
- Misses 31218 31572 +354
|
|
Nice work! Thanks for help with this. I'm happy to see more consistency. |
|
One other thing. In the course of developing this fix, I ran into a problem with dependency Here's details, probably should be noted in release notes... known issuesYou'll note that the sub-microsecond bits of a datetime are truncated when a string is parsed into a datetime. 〉2023-03-02T01:02:03.987654321-05:00 | date to-record
╭────────────┬───────────╮
│ year │ 2023 │
│ month │ 3 │
│ day │ 2 │
│ hour │ 1 │
│ minute │ 2 │
│ second │ 3 │
│ nanosecond │ 987654321 │
│ timezone │ -05:00 │
╰────────────┴───────────╯
〉'2023-03-02T01:02:03.987654321' | into datetime | date to-record
╭────────────┬───────────╮
│ year │ 2023 │
│ month │ 3 │
│ day │ 2 │
│ hour │ 1 │
│ minute │ 2 │
│ second │ 3 │
│ nanosecond │ 987654000 │
│ timezone │ -05:00 │
╰────────────┴───────────╯This is a limitation of dependency |
|
I think this is not too big of a deal as the system clocks also have a varying resolution and accuracy, typically much worse than a nanosecond (thanks side-channel attacks). |
|
@bobhy I'm wondering if I'm having some odd problem. I didn't expect nanos to always end in 000. Is that expected? |
# Description This PR fixes an error message that popped up after landing a PR #8337. I guess there were too many changes since the PR was submitted? # User-Facing Changes _(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)_ # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
#8805) # Description Pick up [enhancement in `dtparse`](bspeice/dtparse#41), to preserve nanoseconds in string-to-date conversions. # User-Facing Changes An especially eagle-eyed user might notice that prior versions of nushell were losing nanosecond precision when converting string format date/time to datetime. Before: ```nushell 〉'2023-03-02T01:02:03.987654321' | into datetime | date to-record ╭────────────┬───────────╮ │ year │ 2023 │ │ month │ 3 │ │ day │ 2 │ │ hour │ 1 │ │ minute │ 2 │ │ second │ 3 │ │ nanosecond │ 987654000 │ │ timezone │ -04:00 │ ╰────────────┴───────────╯ ``` Now, it just works(tm) ```nushell 〉'2023-03-02T01:02:03.987654321' | into datetime | date to-record ╭────────────┬───────────╮ │ year │ 2023 │ │ month │ 3 │ │ day │ 2 │ │ hour │ 1 │ │ minute │ 2 │ │ second │ 3 │ │ nanosecond │ 987654321 │ │ timezone │ -04:00 │ ╰────────────┴───────────╯ ``` # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass Some (unrelated) tests did fail [^err] - [x] `cargo run -- crates/nu-std/tests.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. # (Unrelated) test failures noted [^err]: Several tests are failing, unrelated to this PR ``` failures: ---- modules::module_import_env_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; use main.nu foo; foo · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:316:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- modules::module_import_env_2 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; $env.FOO · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_2' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:341:9 ---- overlays::overlay_use_do_cd_file_relative stdout ---- === stderr thread 'overlays::overlay_use_do_cd_file_relative' panicked at 'assertion failed: `(left == right)` left: `"nushell"`, right: `"test1"`', tests/overlays/mod.rs:919:9 ---- overlays::overlay_use_dont_cd_overlay stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env test1/test2/spam.nu; $env.PWD | path basename · ─────────┬───────── · ╰── file not found ╰──── thread 'overlays::overlay_use_dont_cd_overlay' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"overlay_use_dont_cd_overlay"`', tests/overlays/mod.rs:946:9 ---- parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol.nu; $env.FOO · ─────┬──── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"good"`', tests/parsing/mod.rs:177:9 ---- parsing::parse_file_relative_to_parsed_file_simple stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol/lol.nu; $env.LOL · ───────┬────── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_simple' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"lol"`', tests/parsing/mod.rs:99:9 ---- shell::const_nu_lib_dirs_relative stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[main.nu:1:1] 1 │ const NU_LIB_DIRS = [ 'scripts' ] 2 │ source-env foo.nu · ───┬── thread 'shell::const_nu_lib_dirs_relative' panicked at 'assertion failed: outcome.err.is_empty()', tests/shell/mod.rs:166:9 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"AndrásWithKitKat"`', tests/shell/pipeline/commands/external.rs:198:13 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"jt_likes_cake.txt"`', tests/shell/pipeline/commands/external.rs:173:13 failures: modules::module_import_env_1 modules::module_import_env_2 overlays::overlay_use_do_cd_file_relative overlays::overlay_use_dont_cd_overlay parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 parsing::parse_file_relative_to_parsed_file_simple shell::const_nu_lib_dirs_relative shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings test result: FAILED. 386 passed; 9 failed; 20 ignored; 0 measured; 0 filtered out; finished in 98.06s error: test failed, to rerun pass `-p nu --test main` failures: ---- modules::module_import_env_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; use main.nu foo; foo · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:316:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- modules::module_import_env_2 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; $env.FOO · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_2' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:341:9 ---- overlays::overlay_use_do_cd_file_relative stdout ---- === stderr thread 'overlays::overlay_use_do_cd_file_relative' panicked at 'assertion failed: `(left == right)` left: `"nushell"`, right: `"test1"`', tests/overlays/mod.rs:919:9 ---- overlays::overlay_use_dont_cd_overlay stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env test1/test2/spam.nu; $env.PWD | path basename · ─────────┬───────── · ╰── file not found ╰──── thread 'overlays::overlay_use_dont_cd_overlay' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"overlay_use_dont_cd_overlay"`', tests/overlays/mod.rs:946:9 ---- parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol.nu; $env.FOO · ─────┬──── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"good"`', tests/parsing/mod.rs:177:9 ---- parsing::parse_file_relative_to_parsed_file_simple stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol/lol.nu; $env.LOL · ───────┬────── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_simple' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"lol"`', tests/parsing/mod.rs:99:9 ---- shell::const_nu_lib_dirs_relative stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[main.nu:1:1] 1 │ const NU_LIB_DIRS = [ 'scripts' ] 2 │ source-env foo.nu · ───┬── thread 'shell::const_nu_lib_dirs_relative' panicked at 'assertion failed: outcome.err.is_empty()', tests/shell/mod.rs:166:9 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"AndrásWithKitKat"`', tests/shell/pipeline/commands/external.rs:198:13 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"jt_likes_cake.txt"`', tests/shell/pipeline/commands/external.rs:173:13 failures: modules::module_import_env_1 modules::module_import_env_2 overlays::overlay_use_do_cd_file_relative overlays::overlay_use_dont_cd_overlay parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 parsing::parse_file_relative_to_parsed_file_simple shell::const_nu_lib_dirs_relative shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings test result: FAILED. 386 passed; 9 failed; 20 ignored; 0 measured; 0 filtered out; finished in 98.06s error: test failed, to rerun pass `-p nu --test main` failures: ---- modules::module_import_env_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; use main.nu foo; foo · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:316:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- modules::module_import_env_2 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; $env.FOO · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_2' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:341:9 ---- overlays::overlay_use_do_cd_file_relative stdout ---- === stderr thread 'overlays::overlay_use_do_cd_file_relative' panicked at 'assertion failed: `(left == right)` left: `"nushell"`, right: `"test1"`', tests/overlays/mod.rs:919:9 ---- overlays::overlay_use_dont_cd_overlay stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env test1/test2/spam.nu; $env.PWD | path basename · ─────────┬───────── · ╰── file not found ╰──── thread 'overlays::overlay_use_dont_cd_overlay' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"overlay_use_dont_cd_overlay"`', tests/overlays/mod.rs:946:9 ---- parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol.nu; $env.FOO · ─────┬──── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"good"`', tests/parsing/mod.rs:177:9 ---- parsing::parse_file_relative_to_parsed_file_simple stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol/lol.nu; $env.LOL · ───────┬────── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_simple' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"lol"`', tests/parsing/mod.rs:99:9 ---- shell::const_nu_lib_dirs_relative stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[main.nu:1:1] 1 │ const NU_LIB_DIRS = [ 'scripts' ] 2 │ source-env foo.nu · ───┬── thread 'shell::const_nu_lib_dirs_relative' panicked at 'assertion failed: outcome.err.is_empty()', tests/shell/mod.rs:166:9 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"AndrásWithKitKat"`', tests/shell/pipeline/commands/external.rs:198:13 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"jt_likes_cake.txt"`', tests/shell/pipeline/commands/external.rs:173:13 failures: modules::module_import_env_1 modules::module_import_env_2 overlays::overlay_use_do_cd_file_relative overlays::overlay_use_dont_cd_overlay parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 parsing::parse_file_relative_to_parsed_file_simple shell::const_nu_lib_dirs_relative shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings test result: FAILED. 386 passed; 9 failed; 20 ignored; 0 measured; 0 filtered out; finished in 98.06s error: test failed, to rerun pass `-p nu --test main` ```
…ell#8337 (nushell#8805) # Description Pick up [enhancement in `dtparse`](bspeice/dtparse#41), to preserve nanoseconds in string-to-date conversions. # User-Facing Changes An especially eagle-eyed user might notice that prior versions of nushell were losing nanosecond precision when converting string format date/time to datetime. Before: ```nushell 〉'2023-03-02T01:02:03.987654321' | into datetime | date to-record ╭────────────┬───────────╮ │ year │ 2023 │ │ month │ 3 │ │ day │ 2 │ │ hour │ 1 │ │ minute │ 2 │ │ second │ 3 │ │ nanosecond │ 987654000 │ │ timezone │ -04:00 │ ╰────────────┴───────────╯ ``` Now, it just works(tm) ```nushell 〉'2023-03-02T01:02:03.987654321' | into datetime | date to-record ╭────────────┬───────────╮ │ year │ 2023 │ │ month │ 3 │ │ day │ 2 │ │ hour │ 1 │ │ minute │ 2 │ │ second │ 3 │ │ nanosecond │ 987654321 │ │ timezone │ -04:00 │ ╰────────────┴───────────╯ ``` # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass Some (unrelated) tests did fail [^err] - [x] `cargo run -- crates/nu-std/tests.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. # (Unrelated) test failures noted [^err]: Several tests are failing, unrelated to this PR ``` failures: ---- modules::module_import_env_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; use main.nu foo; foo · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:316:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- modules::module_import_env_2 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; $env.FOO · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_2' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:341:9 ---- overlays::overlay_use_do_cd_file_relative stdout ---- === stderr thread 'overlays::overlay_use_do_cd_file_relative' panicked at 'assertion failed: `(left == right)` left: `"nushell"`, right: `"test1"`', tests/overlays/mod.rs:919:9 ---- overlays::overlay_use_dont_cd_overlay stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env test1/test2/spam.nu; $env.PWD | path basename · ─────────┬───────── · ╰── file not found ╰──── thread 'overlays::overlay_use_dont_cd_overlay' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"overlay_use_dont_cd_overlay"`', tests/overlays/mod.rs:946:9 ---- parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol.nu; $env.FOO · ─────┬──── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"good"`', tests/parsing/mod.rs:177:9 ---- parsing::parse_file_relative_to_parsed_file_simple stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol/lol.nu; $env.LOL · ───────┬────── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_simple' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"lol"`', tests/parsing/mod.rs:99:9 ---- shell::const_nu_lib_dirs_relative stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[main.nu:1:1] 1 │ const NU_LIB_DIRS = [ 'scripts' ] 2 │ source-env foo.nu · ───┬── thread 'shell::const_nu_lib_dirs_relative' panicked at 'assertion failed: outcome.err.is_empty()', tests/shell/mod.rs:166:9 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"AndrásWithKitKat"`', tests/shell/pipeline/commands/external.rs:198:13 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"jt_likes_cake.txt"`', tests/shell/pipeline/commands/external.rs:173:13 failures: modules::module_import_env_1 modules::module_import_env_2 overlays::overlay_use_do_cd_file_relative overlays::overlay_use_dont_cd_overlay parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 parsing::parse_file_relative_to_parsed_file_simple shell::const_nu_lib_dirs_relative shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings test result: FAILED. 386 passed; 9 failed; 20 ignored; 0 measured; 0 filtered out; finished in 98.06s error: test failed, to rerun pass `-p nu --test main` failures: ---- modules::module_import_env_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; use main.nu foo; foo · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:316:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- modules::module_import_env_2 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; $env.FOO · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_2' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:341:9 ---- overlays::overlay_use_do_cd_file_relative stdout ---- === stderr thread 'overlays::overlay_use_do_cd_file_relative' panicked at 'assertion failed: `(left == right)` left: `"nushell"`, right: `"test1"`', tests/overlays/mod.rs:919:9 ---- overlays::overlay_use_dont_cd_overlay stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env test1/test2/spam.nu; $env.PWD | path basename · ─────────┬───────── · ╰── file not found ╰──── thread 'overlays::overlay_use_dont_cd_overlay' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"overlay_use_dont_cd_overlay"`', tests/overlays/mod.rs:946:9 ---- parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol.nu; $env.FOO · ─────┬──── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"good"`', tests/parsing/mod.rs:177:9 ---- parsing::parse_file_relative_to_parsed_file_simple stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol/lol.nu; $env.LOL · ───────┬────── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_simple' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"lol"`', tests/parsing/mod.rs:99:9 ---- shell::const_nu_lib_dirs_relative stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[main.nu:1:1] 1 │ const NU_LIB_DIRS = [ 'scripts' ] 2 │ source-env foo.nu · ───┬── thread 'shell::const_nu_lib_dirs_relative' panicked at 'assertion failed: outcome.err.is_empty()', tests/shell/mod.rs:166:9 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"AndrásWithKitKat"`', tests/shell/pipeline/commands/external.rs:198:13 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"jt_likes_cake.txt"`', tests/shell/pipeline/commands/external.rs:173:13 failures: modules::module_import_env_1 modules::module_import_env_2 overlays::overlay_use_do_cd_file_relative overlays::overlay_use_dont_cd_overlay parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 parsing::parse_file_relative_to_parsed_file_simple shell::const_nu_lib_dirs_relative shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings test result: FAILED. 386 passed; 9 failed; 20 ignored; 0 measured; 0 filtered out; finished in 98.06s error: test failed, to rerun pass `-p nu --test main` failures: ---- modules::module_import_env_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; use main.nu foo; foo · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:316:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- modules::module_import_env_2 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env main.nu; $env.FOO · ───┬─── · ╰── file not found ╰──── thread 'modules::module_import_env_2' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"foo"`', tests/modules/mod.rs:341:9 ---- overlays::overlay_use_do_cd_file_relative stdout ---- === stderr thread 'overlays::overlay_use_do_cd_file_relative' panicked at 'assertion failed: `(left == right)` left: `"nushell"`, right: `"test1"`', tests/overlays/mod.rs:919:9 ---- overlays::overlay_use_dont_cd_overlay stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env test1/test2/spam.nu; $env.PWD | path basename · ─────────┬───────── · ╰── file not found ╰──── thread 'overlays::overlay_use_dont_cd_overlay' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"overlay_use_dont_cd_overlay"`', tests/overlays/mod.rs:946:9 ---- parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol.nu; $env.FOO · ─────┬──── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"good"`', tests/parsing/mod.rs:177:9 ---- parsing::parse_file_relative_to_parsed_file_simple stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[source:1:1] 1 │ source-env lol/lol/lol.nu; $env.LOL · ───────┬────── · ╰── file not found ╰──── thread 'parsing::parse_file_relative_to_parsed_file_simple' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"lol"`', tests/parsing/mod.rs:99:9 ---- shell::const_nu_lib_dirs_relative stdout ---- === stderr Error: nu::shell::file_not_found × File not found ╭─[main.nu:1:1] 1 │ const NU_LIB_DIRS = [ 'scripts' ] 2 │ source-env foo.nu · ───┬── thread 'shell::const_nu_lib_dirs_relative' panicked at 'assertion failed: outcome.err.is_empty()', tests/shell/mod.rs:166:9 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"AndrásWithKitKat"`', tests/shell/pipeline/commands/external.rs:198:13 ---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings stdout ---- === stderr thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings' panicked at 'assertion failed: `(left == right)` left: `""`, right: `"jt_likes_cake.txt"`', tests/shell/pipeline/commands/external.rs:173:13 failures: modules::module_import_env_1 modules::module_import_env_2 overlays::overlay_use_do_cd_file_relative overlays::overlay_use_dont_cd_overlay parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 parsing::parse_file_relative_to_parsed_file_simple shell::const_nu_lib_dirs_relative shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings test result: FAILED. 386 passed; 9 failed; 20 ignored; 0 measured; 0 filtered out; finished in 98.06s error: test failed, to rerun pass `-p nu --test main` ```
|
@bobhy Do you have time to look at something? I believe this PR broke some things. In PR #10055, @amtoine and I thought it would be better to revert this PR. We were initially confused that See #10055 for some ideas about how to fix it. I'm not sure what I'm suggesting is the right course of action. |
|
No, I traced the execution of `'20220604' | into datetime -f '%Y%m%d'` and
found that the input string was properly fed into
`chrono::DateTime<FixedOffset>::parse_from_string()`, but the latter was
failing because the `--format` argument doesn't include a timezone token
(`%z`).
…On Sat, Aug 19, 2023 at 7:29 AM Darren Schroeder ***@***.***> wrote:
@bobhy <https://github.com/bobhy> Do you have time to look at something?
I believe this PR broke some things. In PR #10055
<#10055>, @amtoine
<https://github.com/amtoine> and I thought it would be better to revert
this PR. We were initially confused that into datetime -f some_format
doesn't work. I was confused thinking it was formatting the output, when
all along it was meant to format the input. So, then he puts up 10055 to
revert that. We're noticing that you can't really do '20220604' | into
datetime -f '%Y%m%d' because the logic of the code thinks that date is a
timestamp and parses it incorrectly. Essentially, the logic never gets down
to the --format part so it never runs. It would be great if you have time
to look at this.
—
Reply to this email directly, view it on GitHub
<#8337 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPBIZDE57RLF77IY26J5A3XWDEVLANCNFSM6AAAAAAVQXBAUI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|

Description
Fix for data ambiguity noted in #8244.
Basic change is to use nanosecond resolution for unix timestamps (stored in type Int). Previously, a timestamp might have seconds, milliseconds or nanoseconds, but it turned out there were overlaps in data ranges between different resolutions, so there wasn't always a unique mapping back to date/time.
Due to higher precision, the range of dates that timestamps can map to is restricted. Unix timestamps with seconds resolution and 64 bit storage can cover all dates from the Big Bang to eternity. Timestamps with seconds resolution and 32 bit storage can only represent dates from 1901-12-13 through 2038-01-19. The nanoseconds resolution and 64 bit storage used with this fix can represent dates from 1677-09-21T00:12:44 to 2262-04-11T23:47:16, something of a compromise.
User-Facing Changes
(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)
<datetime> | into intConverts to nanosecond resolution
〉date now | into int 1678084730502126846This is the number of non-leap nanoseconds after the unix epoch date: 1970-01-01T00:00:00+00:00.
Conversion fails for dates outside the supported range:
<int> | into datetimeCan no longer fail or produce incorrect results for any 64-bit input:
<date> | date to-recordand<date> | date to-tableNow both have a
nanosecondfield.This change was not mandated by the OP problem, but it is nice to be able to see the nanosecond bits that were present in Nushell
datetype all along.Tests + Formatting
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --checkto check standard code formatting (cargo fmt --allapplies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectto check that you're using the standard code stylecargo test --workspaceto check that all tests passAfter Submitting
If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.