Given the large number of ways of formatting time to be human readable, I suspect that implementing Display
on anything time-like is going to be a non-starter. Even if we develop some mechanism to format time within the standard library, unless it can be extended by user code it will be problematic. For example, some ancient time keeping systems used to split the day and night such that the day always had 12 hours and the night always had 12 hours... even as the seasons changed and the length of the day/night changed. While I don't think we'd want to use that today, I also don't want to prevent others from implementing it they wish to.
My suggestion is that if we really want to do something about this, we define new traits for the standard library similar to the following:
use std::fmt::Display;
use std::time::Duration;
use std::error::Error;
pub trait DisplayDuration: Display {
/// Sets the `Duration` that will be formatted.
fn set_duration(&mut self, duration: &Duration) -> Result<(), Box<dyn Error>>;
}
and similarly for the other time types.
We provide some simple implementations of the trait that might have some knobs to adjust the format in quasi-standard ways (e.g., an object that emulates strftime()), but end users are free to implement objects that are able to do more esoteric formatting, like for that ancient calendar I mentioned above.
As a side note, my google-fu is weak today; I can't find the name of the particular time system I mentioned earlier. Does anyone know what it is so I can edit this post later on?