Skip to content

Move human date parsing into new command date from-human#15495

Merged
fdncred merged 7 commits intonushell:mainfrom
LoicRiegel:from-human-command
Apr 7, 2025
Merged

Move human date parsing into new command date from-human#15495
fdncred merged 7 commits intonushell:mainfrom
LoicRiegel:from-human-command

Conversation

@LoicRiegel
Copy link
Copy Markdown
Contributor

@LoicRiegel LoicRiegel commented Apr 5, 2025

No related issue.
Decided in nushell's weekly meeting: see meeting notes

Description

Converting a date as a human readable string to a datetime:

  • currently: using the into datetime command
  • after this change: using date from-human command

Also moved the --list-human flag to the new command.

User-Facing Changes

  • Users have to use a new command for parsing human readable datetimes.

Result:

~> date from-human --list
╭────┬───────────────────────────────────┬──────────────╮
  # │ parseable human datetime examples │    result    │
├────┼───────────────────────────────────┼──────────────┤
  0  Today 18:30                        in 6 hours   
  1  2022-11-07 13:25:30                2 years ago  
  2  15:20 Friday                       in 6 days    
  3  This Friday 17:00                  in 6 days    
  4  13:25, Next Tuesday                in 3 days    
  5  Last Friday at 19:45               16 hours ago 
  6  In 3 days                          in 2 days    
  7  In 2 hours                         in 2 hours   
  8  10 hours and 5 minutes ago         10 hours ago 
  9  1 years ago                        a year ago   
 10  A year ago                         a year ago   
 11  A month ago                        a month ago  
 12  A week ago                         a week ago   
 13  A day ago                          a day ago    
 14  An hour ago                        an hour ago  
 15  A minute ago                       a minute ago 
 16  A second ago                       now          
 17  Now                                now          
╰────┴───────────────────────────────────┴──────────────╯

~> "2 days ago" | date from-human
Thu, 3 Apr 2025 12:03:33 +0200 (2 days ago)

~> "2 days ago" | into datetime
Error: nu::shell::datetime_parse_error

  × Unable to parse datetime: [2 days ago].
   ╭─[entry #5:1:1]
 1  "2 days ago" | into datetime
   · ──────┬─────
   ·       ╰── datetime parsing failed
   ╰────
  help: Examples of supported inputs:
         * "5 pm"
         * "2020/12/4"
         * "2020.12.04 22:10 +2"
         * "2020-04-12 22:10:57 +02:00"
         * "2020-04-12T22:10:57.213231+02:00"
         * "Tue, 1 Jul 2003 10:52:37 +0200"

Tests + Formatting

Fmt, clippy 🆗
Tests 🆗

Note: I was able to reactivate one unit test in the into datetime command

After Submitting

Here since the user facing changes are significant, I think we should communicate in the released notes. Otherwise the automatically generated documentation should be enough IMO.

Copy link
Copy Markdown
Member

@sholderbach sholderbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this!

Comment on lines +21 to +23
"list-human",
"Show human-readable datetime parsing examples",
Some('n'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is now a much more narrow command with date from-human this could be shortened to --list I think.

Also the short flag could be -l

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good idea!
Done

@LoicRiegel LoicRiegel force-pushed the from-human-command branch from 4a4c5e8 to 0bc645a Compare April 7, 2025 12:20
@LoicRiegel LoicRiegel force-pushed the from-human-command branch from 0bc645a to 769e989 Compare April 7, 2025 12:24
@fdncred fdncred merged commit 12a1eef into nushell:main Apr 7, 2025
15 checks passed
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 7, 2025

Thanks

@github-actions github-actions bot added this to the v0.104.0 milestone Apr 7, 2025
@LoicRiegel LoicRiegel deleted the from-human-command branch April 7, 2025 12:52
@LoicRiegel
Copy link
Copy Markdown
Contributor Author

I can write you some release notes about that if you want. By the way do you have a channel or something else where you plan and organize before each release?

@sholderbach sholderbach added notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes new-command labels Apr 7, 2025
@LoicRiegel
Copy link
Copy Markdown
Contributor Author

Also @fdncred have you tried human-date-parser 0.3.0? I was thinking we could do the update after this was merged :)
I had a quick look at it yesterday and this is the only place where this create in used in the repo, so it won't affect anything else.
Tell me if you want me to open a PR for that or if you wanna do it :)

@sholderbach
Copy link
Copy Markdown
Member

I thought #15426 was already merged.

We don't have a structured channel for the release process, we tend to do that quite adhoc. The meeting before the release we tend to call who is available for release note editing and the release operation itself. We try to open the release note branch for the next release after the last release (e.g. the current one nushell/nushell.github.io#1836)

@LoicRiegel
Copy link
Copy Markdown
Contributor Author

I thought #15426 was already merged.

I didn't see the PR and the issue was still open, so I didn't notice. But nice :)

We don't have a structured channel for the release process, we tend to do that quite adhoc. The meeting before the release we tend to call who is available for release note editing and the release operation itself. We try to open the release note branch for the next release after the last release (e.g. the current one nushell/nushell.github.io#1836)

Okay, thanks for the info, I'll submit something there

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 7, 2025

ya, i did the 3.0 crate the other day. I didn't really look too close at the new features but the api definitely changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-command notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants