Function date_header::format

source ยท
pub fn format(
    secs_since_epoch: u64,
    buffer: &mut [u8; 29],
) -> Result<(), TooFuturistic>
Expand description

Format a unix timestamp to be used in an HTTP header field into the provided buffer.

Dates are formatted as IMF-fixdate: Fri, 15 May 2015 15:34:21 GMT. This is a fixed-width format, so this function will always overwrite the entire buffer.

Since this is a fixed-width format, it does not support dates greater than year 9999.

let mut header = [0u8; 29];
assert_eq!(Ok(()), date_header::format(1431704061, &mut header));
assert_eq!(&header, b"Fri, 15 May 2015 15:34:21 GMT");