time-rs / time

The most used Rust library for date and time handling.
https://time-rs.github.io
Apache License 2.0
1.13k stars 281 forks source link

`Weekday` and `Time` (and probably more types) do not respect formatting flags #626

Closed jrpear closed 1 year ago

jrpear commented 1 year ago
println!("{:>10}", time::Weekday::Monday);

Gives

Monday

It should give

    Monday

This is because time's Display implementations don't look at the formatting flags on the Formatter passed.

fmt::Formatter::pad can do this automatically.

jhpratt commented 1 year ago

This can definitely be done. A quick look shows that Weekday will be trivial. Time will be slightly more involved, as I'll have to calculate the width up-front. The same is true for other types, I imagine.

jhpratt commented 1 year ago

Done on main.