nushell/crates/nu-command
Loïc Riegel 67b6188b19
feat: into duration accepts floats (#15297)
Issue #9887 which can be closed after this is merged.

# Description

This allows the "into duration" command to accept floats as inputs.

Examples:
<img width="767" alt="image"
src="https://github.com/user-attachments/assets/da181f2a-7ad6-4efb-a6db-f9c6d8929c71"
/>

<img width="710" alt="image"
src="https://github.com/user-attachments/assets/78623a39-33ad-42a0-9324-a147be86f95c"
/>

**How it works:**

Using strings, like `"1.234sec" | into duration`, is already working, so
if a user inputs `1.234 | into duration --sec`, I just convert this back
to a string and use the previous conversion functions.

**Limitations:**

there are some limitation to using floats, but it's a general limitation
that is already present for other use cases:
- only 3 digits are taken into account in the decimal part
- floating durations in nano seconds are always floored and not rounded

<img width="761" alt="image"
src="https://github.com/user-attachments/assets/a9076aab-da03-43f2-927c-c9703fc4f955"
/>


# User-Facing Changes
Users can inject floats with `into duration`

# Tests + Formatting
cargo fmt and clippy OK
Tests OK

# After Submitting
The example I added will automatically become part of the doc, I think
that's enough for documentation.
2025-04-03 14:05:18 +02:00
..
src feat: into duration accepts floats (#15297) 2025-04-03 14:05:18 +02:00
tests remove -s, -p in do (#15456) 2025-04-01 07:17:05 -05:00
Cargo.toml Bump to 0.103.1 dev version (#15347) 2025-03-19 00:12:01 -04:00
LICENSE Fix rest of license year ranges (#8727) 2023-04-04 09:03:29 +12:00
README.md Add top-level crate documentation/READMEs (#12907) 2024-07-14 10:10:41 +02:00

This crate contains the majority of our commands

We allow ourselves to move some of the commands in nu-command to nu-cmd-* crates as needed.

Internal Nushell crate

This crate implements components of Nushell and is not designed to support plugin authors or other users directly.