Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: implement Display for Expires #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/common/expires.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::time::SystemTime;
use std::{fmt, time::SystemTime};

use crate::util::HttpDate;

Expand Down Expand Up @@ -48,3 +48,25 @@ impl From<Expires> for SystemTime {
date.0.into()
}
}

impl fmt::Display for Expires {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}

#[cfg(test)]
mod tests {
use super::super::test_decode;
use super::*;

fn expires(s: &str) -> Expires {
test_decode(&[s]).unwrap()
}

#[test]
fn format() {
let s = "Thu, 01 Dec 1994 16:00:00 GMT";
assert_eq!(expires(s).to_string(), s);
}
}