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

std::fmt::Display implementation of Weekday does not honour width, alignment or fill #1620

Open
horazont opened this issue Oct 13, 2024 · 1 comment

Comments

@horazont
Copy link

Summary

The Display implementation of Weekday uses Formatter::write_str, which doesn't honour width or alignment and fill.

Reproducer

use chrono::Weekday;

fn main() {
    println!("Expected result: <{:X>10}>", format!("{}", Weekday::Mon));
    println!("Actual result: <{:X>10}>", Weekday::Mon);
}

(Playground)

Expected result

<XXXXXXXMon>

Actual result

<Mon>

@horazont
Copy link
Author

Looking further, seems like the easy way out is to use Formatter::pad instead of write_str.

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

No branches or pull requests

1 participant