forked from extern/nushell
e6ce8a89be
# Description This PR tries to fix `into datetime`. The problem was that it didn't support many input formats and the `--format` was clunky. `--format` is still a bit clunky but can work. The big change here is that it first tries to use `dtparse` to convert text into datetime. ### Before ```nushell ❯ '20220604' | into datetime Thu, 01 Jan 1970 00:00:00 +0000 (53 years ago) ``` ### After ```nushell ❯ '20220604' | into datetime Sat, 04 Jun 2022 00:00:00 -0500 (a year ago) ``` ## Supported Input Formats `dtparse` should support all these formats. Taken from their [repo](https://github.com/bspeice/dtparse/blob/master/build_pycompat.py). ```python 'test_parse_default': [ "Thu Sep 25 10:36:28", "Sep 10:36:28", "10:36:28", "10:36", "Sep 2003", "Sep", "2003", "10h36m28.5s", "10h36m28s", "10h36m", "10h", "10 h 36", "10 h 36.5", "36 m 5", "36 m 5 s", "36 m 05", "36 m 05 s", "10h am", "10h pm", "10am", "10pm", "10:00 am", "10:00 pm", "10:00am", "10:00pm", "10:00a.m", "10:00p.m", "10:00a.m.", "10:00p.m.", "October", "31-Dec-00", "0:01:02", "12h 01m02s am", "12:08 PM", "01h02m03", "01h02", "01h02s", "01m02", "01m02h", "2004 10 Apr 11h30m", # testPertain 'Sep 03', 'Sep of 03', # test_hmBY - Note: This appears to be Python 3 only, no idea why '02:17NOV2017', # Weekdays "Thu Sep 10:36:28", "Thu 10:36:28", "Wed", "Wednesday" ], 'test_parse_simple': [ "Thu Sep 25 10:36:28 2003", "Thu Sep 25 2003", "2003-09-25T10:49:41", "2003-09-25T10:49", "2003-09-25T10", "2003-09-25", "20030925T104941", "20030925T1049", "20030925T10", "20030925", "2003-09-25 10:49:41,502", "199709020908", "19970902090807", "2003-09-25", "09-25-2003", "25-09-2003", "10-09-2003", "10-09-03", "2003.09.25", "09.25.2003", "25.09.2003", "10.09.2003", "10.09.03", "2003/09/25", "09/25/2003", "25/09/2003", "10/09/2003", "10/09/03", "2003 09 25", "09 25 2003", "25 09 2003", "10 09 2003", "10 09 03", "25 09 03", "03 25 Sep", "25 03 Sep", " July 4 , 1976 12:01:02 am ", "Wed, July 10, '96", "1996.July.10 AD 12:08 PM", "July 4, 1976", "7 4 1976", "4 jul 1976", "7-4-76", "19760704", "0:01:02 on July 4, 1976", "0:01:02 on July 4, 1976", "July 4, 1976 12:01:02 am", "Mon Jan 2 04:24:27 1995", "04.04.95 00:22", "Jan 1 1999 11:23:34.578", "950404 122212", "3rd of May 2001", "5th of March 2001", "1st of May 2003", '0099-01-01T00:00:00', '0031-01-01T00:00:00', "20080227T21:26:01.123456789", '13NOV2017', '0003-03-04', 'December.0031.30', # testNoYearFirstNoDayFirst '090107', # test_mstridx '2015-15-May', ], 'test_parse_tzinfo': [ 'Thu Sep 25 10:36:28 BRST 2003', '2003 10:36:28 BRST 25 Sep Thu', ], 'test_parse_offset': [ 'Thu, 25 Sep 2003 10:49:41 -0300', '2003-09-25T10:49:41.5-03:00', '2003-09-25T10:49:41-03:00', '20030925T104941.5-0300', '20030925T104941-0300', # dtparse-specific "2018-08-10 10:00:00 UTC+3", "2018-08-10 03:36:47 PM GMT-4", "2018-08-10 04:15:00 AM Z-02:00" ], 'test_parse_dayfirst': [ '10-09-2003', '10.09.2003', '10/09/2003', '10 09 2003', # testDayFirst '090107', # testUnambiguousDayFirst '2015 09 25' ], 'test_parse_yearfirst': [ '10-09-03', '10.09.03', '10/09/03', '10 09 03', # testYearFirst '090107', # testUnambiguousYearFirst '2015 09 25' ], 'test_parse_dfyf': [ # testDayFirstYearFirst '090107', # testUnambiguousDayFirstYearFirst '2015 09 25' ], 'test_unspecified_fallback': [ 'April 2009', 'Feb 2007', 'Feb 2008' ], 'test_parse_ignoretz': [ 'Thu Sep 25 10:36:28 BRST 2003', '1996.07.10 AD at 15:08:56 PDT', 'Tuesday, April 12, 1952 AD 3:30:42pm PST', 'November 5, 1994, 8:15:30 am EST', '1994-11-05T08:15:30-05:00', '1994-11-05T08:15:30Z', '1976-07-04T00:01:02Z', '1986-07-05T08:15:30z', 'Tue Apr 4 00:22:12 PDT 1995' ], 'test_fuzzy_tzinfo': [ 'Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.' ], 'test_fuzzy_tokens_tzinfo': [ 'Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.' ], 'test_fuzzy_simple': [ 'I have a meeting on March 1, 1974', # testFuzzyAMPMProblem 'On June 8th, 2020, I am going to be the first man on Mars', # testFuzzyAMPMProblem 'Meet me at the AM/PM on Sunset at 3:00 AM on December 3rd, 2003', # testFuzzyAMPMProblem 'Meet me at 3:00 AM on December 3rd, 2003 at the AM/PM on Sunset', # testFuzzyAMPMProblem 'Jan 29, 1945 14:45 AM I going to see you there?', # testFuzzyIgnoreAMPM '2017-07-17 06:15:', # test_idx_check ], ``` # 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 -A clippy::result_large_err` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` 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. --> |
||
---|---|---|
.. | ||
nu_plugin_custom_values | ||
nu_plugin_example | ||
nu_plugin_formats | ||
nu_plugin_gstat | ||
nu_plugin_inc | ||
nu_plugin_python | ||
nu_plugin_query | ||
nu-cli | ||
nu-cmd-base | ||
nu-cmd-dataframe | ||
nu-cmd-extra | ||
nu-cmd-lang | ||
nu-color-config | ||
nu-command | ||
nu-engine | ||
nu-explore | ||
nu-glob | ||
nu-json | ||
nu-parser | ||
nu-path | ||
nu-plugin | ||
nu-pretty-hex | ||
nu-protocol | ||
nu-std | ||
nu-system | ||
nu-table | ||
nu-term-grid | ||
nu-test-support | ||
nu-utils | ||
README.md |
Nushell core libraries and plugins
These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.
Foundational libraries are split into two kinds of crates:
- Core crates - those crates that work together to build the Nushell language engine
- Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.
Plugins are likewise also split into two types:
- Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
- Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.