-
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
Implement %j
specifier for std::chrono::duration
#3732
Conversation
%j
specifier for std::chrono::duration%j
specifier for std::chrono::duration
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!
include/fmt/chrono.h
Outdated
if (handle_nan_inf()) return; | ||
return write(days(), 0); |
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.
This can be simplified to
if (!handle_nan_inf()) write(days(), 0);
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.
I did it this way to keep the code stylistically similar to the rest of the handlers which all have the same guard statement in the beginning of the function body. I can change it if you insist though :-)
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.
OK, but at the very least there shouldn't be return
before write
because this is a void function.
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.
Ah, yes you are right of course, not sure where did I get this idea from.
4b4f224
to
26ae9fb
Compare
This adds support for `%j` presentation type for duration types: > "If the type being formatted is a specialization of duration, the decimal number of days without padding." Fixes fmtlib#3643.
26ae9fb
to
78a6117
Compare
Merged, thanks! |
This adds support for `%j` presentation type for duration types: > "If the type being formatted is a specialization of duration, the decimal number of days without padding." Fixes fmtlib#3643.
This adds support for
%j
presentation type for duration types:Fixes #3643.
I assume it isn't needed to handle padding or alternative numeric systems here as neither is mentioned in the specification, thus the implementation is basically one line. (Please correct me if I'm wrong.)