all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox v2 5/5] sys: email: use `epoch_to_rfc2822` from proxmox_time
Date: Mon, 11 Dec 2023 14:29:08 +0100	[thread overview]
Message-ID: <20231211132908.267921-6-l.wagner@proxmox.com> (raw)
In-Reply-To: <20231211132908.267921-1-l.wagner@proxmox.com>

`strftime`'s formatting is locale-dependent. If the system locale was
set to e.g. de_DE.UTF-8, the `Date` header became invalid
(e.g Mo instead of Mon for 'Monday'), tripping up some mail clients
(e.g. KMail).

This commit should fix this by using the new `epoch_to_rfc2822`
function from proxmox_time. Under the hood, this function uses
`strftime_l` with a fixed locale (C).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 proxmox-sys/src/email.rs | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/proxmox-sys/src/email.rs b/proxmox-sys/src/email.rs
index be92f30..85d171d 100644
--- a/proxmox-sys/src/email.rs
+++ b/proxmox-sys/src/email.rs
@@ -63,8 +63,7 @@ pub fn sendmail(
     }
     let _ = writeln!(body, "From: {} <{}>", author, mailfrom);
     let _ = writeln!(body, "To: {}", &recipients);
-    let localtime = proxmox_time::localtime(now)?;
-    let rfc2822_date = proxmox_time::strftime("%a, %d %b %Y %T %z", &localtime)?;
+    let rfc2822_date = proxmox_time::epoch_to_rfc2822(now)?;
     let _ = writeln!(body, "Date: {}", rfc2822_date);
     body.push_str("Auto-Submitted: auto-generated;\n");
 
-- 
2.39.2





WARNING: multiple messages have this Message-ID
From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox v2 5/5] sys: email: use `epoch_to_rfc2822` from proxmox_time
Date: Mon, 11 Dec 2023 14:29:08 +0100	[thread overview]
Message-ID: <20231211132908.267921-6-l.wagner@proxmox.com> (raw)
In-Reply-To: <20231211132908.267921-1-l.wagner@proxmox.com>

`strftime`'s formatting is locale-dependent. If the system locale was
set to e.g. de_DE.UTF-8, the `Date` header became invalid
(e.g Mo instead of Mon for 'Monday'), tripping up some mail clients
(e.g. KMail).

This commit should fix this by using the new `epoch_to_rfc2822`
function from proxmox_time. Under the hood, this function uses
`strftime_l` with a fixed locale (C).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 proxmox-sys/src/email.rs | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/proxmox-sys/src/email.rs b/proxmox-sys/src/email.rs
index be92f30..85d171d 100644
--- a/proxmox-sys/src/email.rs
+++ b/proxmox-sys/src/email.rs
@@ -63,8 +63,7 @@ pub fn sendmail(
     }
     let _ = writeln!(body, "From: {} <{}>", author, mailfrom);
     let _ = writeln!(body, "To: {}", &recipients);
-    let localtime = proxmox_time::localtime(now)?;
-    let rfc2822_date = proxmox_time::strftime("%a, %d %b %Y %T %z", &localtime)?;
+    let rfc2822_date = proxmox_time::epoch_to_rfc2822(now)?;
     let _ = writeln!(body, "Date: {}", rfc2822_date);
     body.push_str("Auto-Submitted: auto-generated;\n");
 
-- 
2.39.2





  parent reply	other threads:[~2023-12-11 13:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11 13:29 [pve-devel] [PATCH proxmox v2 0/5] sys: email: always format 'Date' header with C locale Lukas Wagner
2023-12-11 13:29 ` [pbs-devel] " Lukas Wagner
2023-12-11 13:29 ` [pve-devel] [PATCH proxmox v2 1/5] time: posix: use strftime from the `libc` crate Lukas Wagner
2023-12-11 13:29   ` [pbs-devel] " Lukas Wagner
2023-12-11 13:29 ` [pve-devel] [PATCH proxmox v2 2/5] time: posix: inline vars in string formatting Lukas Wagner
2023-12-11 13:29   ` [pbs-devel] " Lukas Wagner
2023-12-11 13:29 ` [pve-devel] [PATCH proxmox v2 3/5] time: posix: add bindings for strftime_l Lukas Wagner
2023-12-11 13:29   ` [pbs-devel] " Lukas Wagner
2023-12-11 13:29 ` [pve-devel] [PATCH proxmox v2 4/5] time: posix: add epoch_to_rfc2822 Lukas Wagner
2023-12-11 13:29   ` [pbs-devel] " Lukas Wagner
2023-12-11 13:29 ` Lukas Wagner [this message]
2023-12-11 13:29   ` [pbs-devel] [PATCH proxmox v2 5/5] sys: email: use `epoch_to_rfc2822` from proxmox_time Lukas Wagner
2024-01-08 10:42 ` [pve-devel] [PATCH proxmox v2 0/5] sys: email: always format 'Date' header with C locale Lukas Wagner
2024-01-08 10:42   ` [pbs-devel] " Lukas Wagner
2024-01-08 11:13 ` [pve-devel] applied-series: " Wolfgang Bumiller
2024-01-08 11:13   ` [pbs-devel] " Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231211132908.267921-6-l.wagner@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal