fix(header): fix fmt_header outputs of several headers

Closes #246
This commit is contained in:
Sean McArthur
2015-01-13 10:42:01 -08:00
parent cfebdabc1a
commit aa26665367
11 changed files with 45 additions and 62 deletions

View File

@@ -1,4 +1,4 @@
use std::fmt::{self, Show};
use std::fmt;
use std::str::FromStr;
use time::Tm;
use header::{Header, HeaderFormat};
@@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str;
use header::shared::time::tm_from_str;
/// The `If-Modified-Since` header field.
#[derive(Copy, PartialEq, Clone)]
#[derive(Copy, PartialEq, Clone, Show)]
pub struct IfModifiedSince(pub Tm);
deref!(IfModifiedSince => Tm);
@@ -24,11 +24,12 @@ impl Header for IfModifiedSince {
impl HeaderFormat for IfModifiedSince {
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let tm = **self;
match tm.tm_utcoff {
0 => tm.rfc822().fmt(fmt),
_ => tm.to_utc().rfc822().fmt(fmt)
}
let tm = self.0;
let tm = match tm.tm_utcoff {
0 => tm,
_ => tm.to_utc(),
};
fmt::String::fmt(&tm.rfc822(), fmt)
}
}