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

formatting chrono with padding #3237

Closed
jengelh opened this issue Dec 21, 2022 · 2 comments · Fixed by #3260
Closed

formatting chrono with padding #3237

jengelh opened this issue Dec 21, 2022 · 2 comments · Fixed by #3260

Comments

@jengelh
Copy link

jengelh commented Dec 21, 2022

The grammar in the documentation

   replacement_field: "{" [`arg_id`] [":" (`format_spec` | `chrono_format_spec`)] "}"

   chrono_format_spec: [[`fill`]`align`][`width`]["." `precision`][`chrono_specs`]
   chrono_specs: [`chrono_specs`] `conversion_spec` | `chrono_specs` `literal_char`
   conversion_spec: "%" [`modifier`] `chrono_type`

suggests to me that {:>30%H} is valid, but this is not what fmt-9.1.0 and/or master @ b908954 outputs.

Input:

#include <chrono>
#include <fmt/core.h>
#include <fmt/chrono.h>
int main()
{
        fmt::print("{:>30d}\n", 30);
        fmt::print("{:>30%H:%M}\n", std::chrono::system_clock::now());
}

Output:

                            30
>3023:48

Expected:

                            30
                         23:48
@vitaut
Copy link
Contributor

vitaut commented Dec 21, 2022

Formatting of time points is still WIP and only supports chrono_specs at the moment. PRs to add support for other specifiers are welcome.

@jengelh
Copy link
Author

jengelh commented Dec 21, 2022

Or maybe we can edit the documentation until that's supported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants