Use Tm::rfc822z to support local timezones (workaround for time crate incomplete feature)
This commit is contained in:
@@ -166,7 +166,7 @@ impl EmailBuilder {
|
|||||||
|
|
||||||
/// Adds a `Date` header with the given date
|
/// Adds a `Date` header with the given date
|
||||||
pub fn date(mut self, date: &Tm) -> EmailBuilder {
|
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.date_issued = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ impl EmailBuilder {
|
|||||||
/// Build the Email
|
/// Build the Email
|
||||||
pub fn build(mut self) -> Email {
|
pub fn build(mut self) -> Email {
|
||||||
if !self.date_issued {
|
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.message.update_headers();
|
||||||
self.content
|
self.content
|
||||||
@@ -318,7 +318,7 @@ mod test {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{}", email),
|
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",
|
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())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user