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

Tweak corresponding quantity for main chrono types #276

Merged
merged 5 commits into from
Aug 5, 2024

Conversation

chiphogg
Copy link
Contributor

@chiphogg chiphogg commented 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.

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 chiphogg added the release notes: ✨ lib (enhancement) PR enhancing the library code label Aug 2, 2024
@chiphogg chiphogg requested a review from geoffviola August 2, 2024 15:41
Copy link
Contributor

@geoffviola geoffviola left a comment

Choose a reason for hiding this comment

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

Looks useful. Tests look good.

@chiphogg chiphogg merged commit f77cc5e into main Aug 5, 2024
11 checks passed
@chiphogg chiphogg deleted the chiphogg/prefixed-seconds#216 branch August 5, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: ✨ lib (enhancement) PR enhancing the library code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use prefixed seconds when possible for chrono-equivalent units
3 participants