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

Use prefixed seconds when possible for chrono-equivalent units #216

Closed
chiphogg opened this issue Jan 19, 2024 · 1 comment · Fixed by #276
Closed

Use prefixed seconds when possible for chrono-equivalent units #216

chiphogg opened this issue Jan 19, 2024 · 1 comment · Fixed by #276
Labels
⬇️ affects: code (interfaces) Affects the way end users will interact with the library 📁 kind: enhancement New feature or request 💪 effort: small
Milestone

Comments

@chiphogg
Copy link
Contributor

chiphogg commented Jan 19, 2024

See this link for current behaviour:

https://godbolt.org/z/vvsaz4Y3a

We could create a utility template that says, effectively, "if any of these prefixes produces a quantity-equivalent unit, then use that instead of just the unit-and-mag".

Of course, once #85 gets fixed, we won't see [UNLABELED_UNIT]; we'll see something like [1 / 1000000000] s. But the prefixes would be a nicer user experience.

@chiphogg chiphogg added 📁 kind: enhancement New feature or request 💪 effort: small ⬇️ affects: code (interfaces) Affects the way end users will interact with the library labels Jan 19, 2024
@chiphogg chiphogg added this to the 0.4.0 milestone Jan 19, 2024
@chiphogg chiphogg modified the milestones: 0.4.0, 0.3.5 Mar 7, 2024
@chiphogg chiphogg modified the milestones: 0.3.5, 0.3.6 Jul 22, 2024
chiphogg added a commit that referenced this issue Aug 2, 2024
Currently, we have a single generic correspondence for all chrono
durations.  This is perfectly unit safe, but it means we have no labels
for any duration type, including common types like `std::chrono::hours`.
This means that `as_quantity(std::chrono::hours{3})` would print as
`"3 [UNLABELED UNIT]"` instead of `"3 h"`.

This PR defines a special correspondence for each commonly used chrono
duration type, which fixes the above behaviour.

As part of doing this, we found a missing dependency on `:quantity`, so
we added it in the BUILD file.

Fixes #216.
@chiphogg
Copy link
Contributor Author

chiphogg commented Aug 5, 2024

Update: fixed on main (https://godbolt.org/z/Kxe8vrh48).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⬇️ affects: code (interfaces) Affects the way end users will interact with the library 📁 kind: enhancement New feature or request 💪 effort: small
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant