pub fn strftime(
time: &impl Time,
format: &[u8],
buf: &mut dyn Write,
) -> Result<(), Error>
Available on crate feature
std
only.Expand description
Format a time implementation with the specified format byte string,
writing to the provided std::io::Write
object.
See the crate-level documentation for a complete description of possible format specifiers.
§Allocations
This strftime
implementation makes no heap allocations on its own, but
the provided writer may allocate.
§Examples
use strftime::io::strftime;
use strftime::Time;
// Not shown: create a time implementation with the year 1970
// let time = ...;
assert_eq!(time.year(), 1970);
let mut buf = Vec::new();
strftime(&time, b"%Y", &mut buf)?;
assert_eq!(buf, *b"1970");
§Errors
Can produce an Error
when the formatting fails.