-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Allow customisation of padding character for chrono #3516
Comments
Thanks for the suggestion but these format specs mostly follow |
Ah, didn’t realise there was a standard around these things. Thanks for letting me know! What a pity that C That being said, one Python resource suggests that |
|
In that case, there must be a bug, because this program: #include <fmt/chrono.h>
int main() {
auto t = tm();
t.tm_year = 2010 - 1900;
t.tm_mon = 7;
t.tm_mday = 4;
t.tm_hour = 1;
t.tm_min = 15;
t.tm_sec = 58;
fmt::print("{:%-I}", t);
return 0;
} Fails with the following error message:
Whereas the same program works fine when I use |
Works on godbolt: https://godbolt.org/z/3Gona4K4P. You might be using an older version. |
A-ha, so I am!
And indeed, when I try that version on Godbolt, it gives that error. I wonder why the Arch package is lagging behind… in any case, apologies for cluttering up the repo with this issue! |
Reading through the chrono documentation, it appears there is no easy way to customise the padding/prefix character for presentation types like
C
,d
,e
,g
,H
,I
, etc. Thus, it seems impossible for me to format a time string like ‘1:08 PM’: the closest I can get is ‘01:08 PM’. It would be nice to have a way to customise the padding character… perhaps themodifier
field could be extended so that characters other thanE
orO
are treated as the character to use?The text was updated successfully, but these errors were encountered: