Skip to content

Fixed to/from toml date format - #11846

Merged
fdncred merged 6 commits into
nushell:mainfrom
dannou812:dannou812/toml-date-format-fix
Feb 14, 2024
Merged

fdncred merged 6 commits into
nushell:mainfrom
dannou812:dannou812/toml-date-format-fix

Conversation

@dannou812

@dannou812 dannou812 commented Feb 13, 2024 •

Copy link
Copy Markdown
Contributor

With this PR i try to resolve #11751

Description

I am rather new to Rust so if anything is not the way it should be please let me know.

As described in the title I just fixed the date conversion in the to and from toml commands as i thought it would be a good first issue. The example of the original issue will now work as follows:

~> {date: 2024-02-02} | to toml
date = "2024-02-02T00:00:00+00:00"
~> "dob = 1979-05-27T07:32:00-08:00" | from toml
╭─────┬───────────────────────────╮
│ dob │ 44 years ago              |
╰─────┴───────────────────────────╯

The from toml command now returns a nushell date which is displayed as 44 years ago in this case.

User-Facing Changes

none

Tests + Formatting

all tests pass and formatting has been applied

@fdncred fdncred added the deprecated:pr-commands (deprecated: too vague) This PR changes our commands in some way label Feb 13, 2024

@fdncred fdncred left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this PR. It seems like a pretty small change. For your first rust PR I'd like to say, good job! There are just a few minor changes that I think we need.

It would also be good to have a test in order to ensure this functionality continues to work as other people make changes.

Co-authored-by: Darren Schroeder <[email protected]>
@dannou812

Copy link
Copy Markdown
Contributor Author

I've added tests for both commands now. Also I removed the unwrap() call and replaced it with an expect() call

@fdncred
fdncred merged commit b060044 into nushell:main Feb 14, 2024
@fdncred

fdncred commented Feb 14, 2024

Copy link
Copy Markdown
Contributor

Thanks!

@hustcer hustcer added this to the v0.91.0 milestone Feb 15, 2024
@kubouch kubouch added the notes:fixes Noted in "Bug fixes" section label Feb 16, 2024
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
With this PR i try to resolve nushell#11751 

# Description
I am rather new to Rust so if anything is not the way it should be
please let me know.

As described in the title I just fixed the date conversion in the to and
from toml commands as i thought it would be a good first issue. The
example of the original issue will now work as follows:

```
~> {date: 2024-02-02} | to toml
date = "2024-02-02T00:00:00+00:00"
~> "dob = 1979-05-27T07:32:00-08:00" | from toml
╭─────┬───────────────────────────╮
│ dob │ 44 years ago              |
╰─────┴───────────────────────────╯
```

The `from toml` command now returns a nushell date which is displayed as
`44 years ago` in this case.

# User-Facing Changes
none

# Tests + Formatting
all tests pass and formatting has been applied

---------

Co-authored-by: dannou812 <[email protected]>
Co-authored-by: Darren Schroeder <[email protected]>
kik4444 pushed a commit to kik4444/nushell-fork that referenced this pull request Feb 28, 2024
With this PR i try to resolve nushell#11751 

# Description
I am rather new to Rust so if anything is not the way it should be
please let me know.

As described in the title I just fixed the date conversion in the to and
from toml commands as i thought it would be a good first issue. The
example of the original issue will now work as follows:

```
~> {date: 2024-02-02} | to toml
date = "2024-02-02T00:00:00+00:00"
~> "dob = 1979-05-27T07:32:00-08:00" | from toml
╭─────┬───────────────────────────╮
│ dob │ 44 years ago              |
╰─────┴───────────────────────────╯
```

The `from toml` command now returns a nushell date which is displayed as
`44 years ago` in this case.

# User-Facing Changes
none

# Tests + Formatting
all tests pass and formatting has been applied

---------

Co-authored-by: dannou812 <[email protected]>
Co-authored-by: Darren Schroeder <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecated:pr-commands (deprecated: too vague) This PR changes our commands in some way notes:fixes Noted in "Bug fixes" section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

to/from toml doesn't use native TOML date format

4 participants