dtt

Macro dtt_format

Source
macro_rules! dtt_format {
    ($dt:expr, $format:expr) => { ... };
}
Expand description

Formats a DateTime object using the provided format string.

§Arguments

  • $dt:expr: The DateTime object to be formatted.
  • $format:expr: The format string to use for formatting the DateTime object.

§Example

use dtt::{dtt_format, dtt_parse};
use time::Month;

let dt = dtt_parse!("2023-01-01T12:00:00+00:00").unwrap();
let formatted = dtt_format!(
    dt,
    "{year}-{month}-{day}T{hour}:{minute}:{second}.{microsecond}{offset_sign}{offset_hour}:{offset_minute}"
);
assert_eq!(formatted, "2023-01-01T12:00:00.000000+00:00");