Skip to content

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

Description

@kaathewisegit

Describe the bug

When converting dates to toml, dates are converted to a string instead of the TOML dates. The same applies to the from conversion.

How to reproduce

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

Expected behavior

Converting Nushell dates to TOML dates and visa versa.

Screenshots

No response

Configuration

key value
version 0.89.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-alpine-linux-musl
rust_version rustc 1.72.1 (d5c2e9c34 2023-09-13) (Alpine Linux 1.72.1-r0)
cargo_version cargo 1.72.1
build_time 2024-01-13 03:02:49 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins

Additional context

No response

Activity

  1. added
    status:needs-triage
    on Feb 5, 2024
  2. fdncred commented on Feb 5, 2024

    @fdncred
    Contributor

    What are "TOML dates"? How do they differ?

  3. kaathewisegit commented on Feb 5, 2024

    @kaathewisegit
    ContributorAuthor

    @fdncred, TOML has first-class date/time support: https://toml.io/en/v1.0.0#offset-date-time

    This allows to store dates in TOML without converting them to and from strings.

  4. fdncred commented on Feb 5, 2024

    @fdncred
    Contributor

    Ah, ok. So, it has to be RFC3339 format. That should be an easy update somewhere in the to/from toml code for anyone interested in changing it.

  5. added a commit that references this issue on Feb 14, 2024
    b060044
  6. added this to the v0.91.0 milestone on Feb 17, 2024
  7. added a commit that references this issue on Feb 20, 2024
    b4c1541
  8. added a commit that references this issue on Feb 28, 2024
    1fddc51
  9. VinciTec commented on May 13, 2024

    @VinciTec

    PR #11846 seems to have correctly parsed the datetime into the RFC3339 format and works correctly for reading (from toml). However, writing to a TOML string (to toml) the found string stores the datetime as a TOML string entry instead of as a Datetime because it is surrounded by quotation marks ( " ). As it seems to me, this is not the way datetime should be stored according to the TOML specifications https://toml.io/en/v1.0.0.

    Example

    ~> {date: 2024-05-13} | to toml
    date = "2024-05-13T00:00:00+00:00"
    

    While the expected behavior is;

    ~> {date: 2024-05-13} | to toml
    date = 2024-05-13T00:00:00+00:00
    

    so just removing the quotation marks. I image this would be an easy change.

  10. kaathewisegit commented on May 30, 2024

    @kaathewisegit
    ContributorAuthor

    @fdncred can You reopen this issue to track the to toml part of it, please?

  11. added a commit that references this issue on Jun 7, 2024
    2d0a60a
  12. modified the milestones: v0.91.0, v0.95.0 on Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions