Skip to content

Commit

Permalink
Use Tm::rfc822z to support local timezones (workaround for time crate…
Browse files Browse the repository at this point in the history
… incomplete feature)
  • Loading branch information
amousset committed Oct 6, 2015
1 parent 813f09a commit 5bedba4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ impl EmailBuilder {

/// Adds a `Date` header with the given date
pub fn date(mut self, date: &Tm) -> EmailBuilder {
self.insert_header(("Date", Tm::rfc822(date).to_string().as_ref()));
self.insert_header(("Date", Tm::rfc822z(date).to_string().as_ref()));
self.date_issued = true;
self
}

/// Build the Email
pub fn build(mut self) -> Email {
if !self.date_issued {
self.insert_header(("Date", Tm::rfc822(&now()).to_string().as_ref()));
self.insert_header(("Date", Tm::rfc822z(&now()).to_string().as_ref()));
}
self.content.message.update_headers();
self.content
Expand Down Expand Up @@ -318,7 +318,7 @@ mod test {
assert_eq!(
format!("{}", email),
format!("Message-ID: <{}@rust-smtp>\r\nTo: <user@localhost>\r\nFrom: <user@localhost>\r\nCc: \"Alias\" <cc@localhost>\r\nReply-To: <reply@localhost>\r\nSender: <sender@localhost>\r\nDate: {}\r\nSubject: Hello\r\nX-test: value\r\n\r\nHello World!\r\n",
email.message_id().unwrap(), date_now.rfc822())
email.message_id().unwrap(), date_now.rfc822z())
);
}

Expand Down

0 comments on commit 5bedba4

Please sign in to comment.