-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add precision modifier for seconds in chrono format #3122
Add precision modifier for seconds in chrono format #3122
Conversation
Thanks for the PR. Is this feature part of the standard? |
No, it is not in standard. The standard only supports the precision modifier for strings and floating point numbers. Precision available only for particular argument, but not for format-spec. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Adding precision support to durations sounds reasonable but for consistency with the standard it should go at the beginning, not in %S
(https://eel.is/c++draft/time.format), e.g.
fmt::print("{:.6%S}", std::chrono::nanoseconds{1234});
It is not obvious for user to use |
We should make existing precision apply to |
Oh, I squashed last commits to resolve conflict. It led to close this PR. @vitaut, please reopen it, I made changes. Now it should work. |
I am not able to reopen this diff for some reason. Please submit a new one. |
Add precision modifier for seconds in chrono format and test for it.
It's became important for custom datetime types that store date, time and subseconds. I want to use chrono format for those types, but I have no way to control subsecond precision.
Use case: