Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rounding Issues in format duration #12858

Open
fennewald opened this issue May 13, 2024 · 3 comments · May be fixed by #12872
Open

Rounding Issues in format duration #12858

fennewald opened this issue May 13, 2024 · 3 comments · May be fixed by #12872
Labels
🐛 bug Something isn't working parser Issues related to parsing

Comments

@fennewald
Copy link
Contributor

Describe the bug

Formatting fractional durations appears to do some weird intermediate rounding.

How to reproduce

  • 1.07min | format duration ms returns 64000 ms, despite the correct answer being 64200 ms.
  • 1.07 min | format duration sec return 64 sec, and not the correct 64.2 sec.

Expected behavior

Correctly format durations, accounting for the precision of the output unit.

Screenshots

No response

Configuration

key value
version 0.93.1
major 0
minor 93
patch 1
branch main
commit_hash 905ec88
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.77.2 (25ef9e3d8 2024-04-09)
rust_channel 1.77.2-x86_64-unknown-linux-gnu
cargo_version cargo 1.77.2 (e52e36006 2024-03-26)
build_time 2024-05-13 18:32:16 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, system-clipboard, trash, which
installed_plugins

Additional context

No response

@fennewald fennewald added the needs-triage An issue that hasn't had any proper look label May 13, 2024
@fennewald
Copy link
Contributor Author

Interesting, related note: 1.07min / 1sec returns 64, not 64.2

@fennewald
Copy link
Contributor Author

fennewald commented May 13, 2024

and 1.07min / 1ms returns 64000, and not the correct 64200. Perhaps it is not format duration, but nushell's internal duration math itself

@fdncred
Copy link
Collaborator

fdncred commented May 13, 2024

Sounds like floats aren't handled right?

@sholderbach sholderbach added 🐛 bug Something isn't working parser Issues related to parsing and removed needs-triage An issue that hasn't had any proper look labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working parser Issues related to parsing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants