use std::time::SystemTime;
use chrono::{DateTime, Utc};
use headers::LastModified;
pub trait LastModifiedExt: seal::Sealed {
fn to_date_time(&self) -> DateTime<Utc>;
fn from_date_time(val: DateTime<Utc>) -> Self;
fn derive_etag(&self) -> String;
}
impl LastModifiedExt for LastModified {
#[inline]
fn to_date_time(&self) -> DateTime<Utc> {
DateTime::<Utc>::from(SystemTime::from(*self))
}
#[inline]
fn from_date_time(val: DateTime<Utc>) -> Self {
Self::from(SystemTime::from(val))
}
#[inline]
fn derive_etag(&self) -> String {
format!("\"{}\"", self.to_date_time().timestamp())
}
}
mod seal {
use headers::LastModified;
pub trait Sealed {}
impl Sealed for LastModified {}
}