Repository: lettre/lettre (language: rust)

Issue:
Date timezone should be "+0000"
Hey folks. Thanks for your continued work on this lib, great to see there's progress towards 0.10.0 :)

The `Date` header that lettre [currently emits](https://github.com/lettre/lettre/blob/efa0d5877832f35aee46a01a679d1fcdca5a5014/src/message/header/date.rs#L54) uses "-0000" as timzone indicator. This is syntactically correct, however I believe it is not what's semantically intended:

As specified in [rfc2822 section 3.3](https://datatracker.ietf.org/doc/html/rfc2822#section-3.3), a timezone of "-0000" indicates that there is no info about a timezone, and a system may or may not be in a local timezone that it can't or won't specify. Given that the code replaces "GMT", the timezone in question is UTC and should be indicated as "+0000".


Discussion / hints:

Fix patch:
diff --git a/src/message/header/date.rs b/src/message/header/date.rs
index 0b56ef1ad..02dec3aa9 100644
--- a/src/message/header/date.rs
+++ b/src/message/header/date.rs
@@ -32,11 +32,11 @@ impl Header for Date {
 
     fn parse(s: &str) -> Result<Self, BoxError> {
         let mut s = String::from(s);
-        if s.ends_with(" -0000") {
+        if s.ends_with("+0000") {
             // The httpdate crate expects the `Date` to end in ` GMT`, but email
-            // uses `-0000`, so we crudely fix this issue here.
+            // uses `+0000` to indicate UTC, so we crudely fix this issue here.
 
-            s.truncate(s.len() - "-0000".len());
+            s.truncate(s.len() - "+0000".len());
             s.push_str("GMT");
         }
 
@@ -49,9 +49,9 @@ impl Header for Date {
             // The httpdate crate always appends ` GMT` to the end of the string,
             // but this is considered an obsolete date format for email
             // https://tools.ietf.org/html/rfc2822#appendix-A.6.2,
-            // so we replace `GMT` with `-0000`
+            // so we replace `GMT` with `+0000`
             val.truncate(val.len() - "GMT".len());
-            val.push_str("-0000");
+            val.push_str("+0000");
         }
 
         HeaderValue::dangerous_new_pre_encoded(Self::name(), val.clone(), val)
@@ -88,7 +88,7 @@ mod test {
 
         assert_eq!(
             headers.to_string(),
-            "Date: Tue, 15 Nov 1994 08:12:31 -0000\r\n".to_string()
+            "Date: Tue, 15 Nov 1994 08:12:31 +0000\r\n".to_string()
         );
 
         // Tue, 15 Nov 1994 08:12:32 GMT
@@ -98,7 +98,7 @@ mod test {
 
         assert_eq!(
             headers.to_string(),
-            "Date: Tue, 15 Nov 1994 08:12:32 -0000\r\n"
+            "Date: Tue, 15 Nov 1994 08:12:32 +0000\r\n"
         );
     }
 
@@ -108,7 +108,7 @@ mod test {
 
         headers.insert_raw(HeaderValue::new(
             HeaderName::new_from_ascii_str("Date"),
-            "Tue, 15 Nov 1994 08:12:31 -0000".to_string(),
+            "Tue, 15 Nov 1994 08:12:31 +0000".to_string(),
         ));
 
         assert_eq!(
@@ -120,7 +120,7 @@ mod test {
 
         headers.insert_raw(HeaderValue::new(
             HeaderName::new_from_ascii_str("Date"),
-            "Tue, 15 Nov 1994 08:12:32 -0000".to_string(),
+            "Tue, 15 Nov 1994 08:12:32 +0000".to_string(),
         ));
 
         assert_eq!(
diff --git a/src/message/mod.rs b/src/message/mod.rs
index 1d02163ef..8791c9fb2 100644
--- a/src/message/mod.rs
+++ b/src/message/mod.rs
@@ -650,7 +650,7 @@ mod test {
         assert_eq!(
             String::from_utf8(email.formatted()).unwrap(),
             concat!(
-                "Date: Tue, 15 Nov 1994 08:12:31 -0000\r\n",
+                "Date: Tue, 15 Nov 1994 08:12:31 +0000\r\n",
                 "From: =?utf-8?b?0JrQsNC4?= <kayo@example.com>\r\n",
                 "To: \"Pony O.P.\" <pony@domain.tld>\r\n",
                 "Subject: =?utf-8?b?0Y/So9CwINC10Lsg0LHQtdC705nQvSE=?=\r\n",


Test patch:
diff --git a/testdata/email_with_png.eml b/testdata/email_with_png.eml
index a00c8b4a8..fc5f49686 100644
--- a/testdata/email_with_png.eml
+++ b/testdata/email_with_png.eml
@@ -1,4 +1,4 @@
-Date: Tue, 15 Nov 1994 08:12:31 -0000
+Date: Tue, 15 Nov 1994 08:12:31 +0000
 From: NoBody <nobody@domain.tld>
 Reply-To: Yuin <yuin@domain.tld>
 To: Hei <hei@domain.tld>
diff --git a/tests/transport_file.rs b/tests/transport_file.rs
index 76267fa01..70c5cf540 100644
--- a/tests/transport_file.rs
+++ b/tests/transport_file.rs
@@ -43,7 +43,7 @@ mod sync {
                 "Reply-To: Yuin <yuin@domain.tld>\r\n",
                 "To: Hei <hei@domain.tld>\r\n",
                 "Subject: Happy new year\r\n",
-                "Date: Tue, 15 Nov 1994 08:12:31 -0000\r\n",
+                "Date: Tue, 15 Nov 1994 08:12:31 +0000\r\n",
                 "Content-Transfer-Encoding: 7bit\r\n",
                 "\r\n",
                 "Be happy!"
@@ -81,7 +81,7 @@ mod sync {
                 "Reply-To: Yuin <yuin@domain.tld>\r\n",
                 "To: Hei <hei@domain.tld>\r\n",
                 "Subject: Happy new year\r\n",
-                "Date: Tue, 15 Nov 1994 08:12:31 -0000\r\n",
+                "Date: Tue, 15 Nov 1994 08:12:31 +0000\r\n",
                 "Content-Transfer-Encoding: 7bit\r\n",
                 "\r\n",
                 "Be happy!"
@@ -141,7 +141,7 @@ mod tokio_1 {
                 "Reply-To: Yuin <yuin@domain.tld>\r\n",
                 "To: Hei <hei@domain.tld>\r\n",
                 "Subject: Happy new year\r\n",
-                "Date: Tue, 15 Nov 1994 08:12:31 -0000\r\n",
+                "Date: Tue, 15 Nov 1994 08:12:31 +0000\r\n",
                 "Content-Transfer-Encoding: 7bit\r\n",
                 "\r\n",
                 "Be happy!"
@@ -192,7 +192,7 @@ mod asyncstd_1 {
                 "Reply-To: Yuin <yuin@domain.tld>\r\n",
                 "To: Hei <hei@domain.tld>\r\n",
                 "Subject: Happy new year\r\n",
-                "Date: Tue, 15 Nov 1994 08:12:31 -0000\r\n",
+                "Date: Tue, 15 Nov 1994 08:12:31 +0000\r\n",
                 "Content-Transfer-Encoding: 7bit\r\n",
                 "\r\n",
                 "Be happy!"