~kevin8t8/mutt-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
5 2

[PATCH] Add local_date_header option

Details
Message ID
<20210514210541.74405-1-greg@gpanders.com>
DKIM signature
missing
Download raw message
Patch: +16 -2
Add an option to convert the date used in the Date header into the local
(sender's) timezone. This is the current behavior and the option
defaults to true. Unsetting this option causes the date in the Date
header to be formatted using the GMT timezone.

This option is useful for privacy-sensitive users who may not wish to
divulge their sending timezone.
---
 init.h    |  6 ++++++
 mutt.h    |  1 +
 sendlib.c | 11 +++++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/init.h b/init.h
index 7590b315..acc7d8b2 100644
--- a/init.h
+++ b/init.h
@@ -1954,6 +1954,12 @@ struct option_t MuttVars[] = {
  ** from your spool mailbox to your $$mbox mailbox, or as a result of
  ** a ``$mbox-hook'' command.
  */
  { "local_date_header", DT_BOOL, R_NONE, {.l=OPTLOCALDATEHEADER}, {.l=1} },
  /*
  ** .pp
  ** If \fIset\fP, convert the date in the Date header of sent emails into local
  ** (sender's) timezone.
  */
  { "mail_check",	DT_NUM,  R_NONE, {.p=&BuffyTimeout}, {.l=5} },
  /*
  ** .pp
diff --git a/mutt.h b/mutt.h
index b7f9d234..88b71da5 100644
--- a/mutt.h
+++ b/mutt.h
@@ -480,6 +480,7 @@ enum
  OPTINCLUDEENCRYPTED,
  OPTINCLUDEONLYFIRST,
  OPTKEEPFLAGGED,
  OPTLOCALDATEHEADER,
  OPTMUTTLISPINLINEEVAL,
  OPTMAILCAPSANITIZE,
  OPTMAILCHECKRECENT,
diff --git a/sendlib.c b/sendlib.c
index 36264aa0..037219dd 100644
--- a/sendlib.c
+++ b/sendlib.c
@@ -1759,8 +1759,15 @@ BODY *mutt_remove_multipart_alternative (BODY *b)
void mutt_make_date (BUFFER *s)
{
  time_t t = time (NULL);
  struct tm *l = localtime (&t);
  time_t tz = mutt_local_tz (t);
  struct tm *l;
  time_t tz = 0;

  if (option (OPTLOCALDATEHEADER)) {
    l = localtime (&t);
    tz = mutt_local_tz (t);
  } else {
    l = gmtime (&t);
  }

  tz /= 60;

-- 
2.31.1
Details
Message ID
<YJ7x5bxCpdMj5X7W@afu.lan>
In-Reply-To
<20210514210541.74405-1-greg@gpanders.com> (view parent)
DKIM signature
missing
Download raw message
On Fri, May 14, 2021 at 03:05:41PM -0600, Gregory Anders wrote:
>Add an option to convert the date used in the Date header into the local
>(sender's) timezone. This is the current behavior and the option
>defaults to true. Unsetting this option causes the date in the Date
>header to be formatted using the GMT timezone.

Hi Gregory,

I think this is okay.  Just a minor formatting nitpick below:

>diff --git a/sendlib.c b/sendlib.c
>index 36264aa0..037219dd 100644
>--- a/sendlib.c
>+++ b/sendlib.c
>@@ -1759,8 +1759,15 @@ BODY *mutt_remove_multipart_alternative (BODY *b)
> void mutt_make_date (BUFFER *s)
> {
>   time_t t = time (NULL);
>-  struct tm *l = localtime (&t);
>-  time_t tz = mutt_local_tz (t);
>+  struct tm *l;
>+  time_t tz = 0;
>+
>+  if (option (OPTLOCALDATEHEADER)) {
>+    l = localtime (&t);
>+    tz = mutt_local_tz (t);
>+  } else {
>+    l = gmtime (&t);
>+  }


Mutt puts the curly brakets on separate lines.  You can leave off curly 
brackets for the else if you like.

  if (option (OPTLOCALDATEHEADER))
  {
    l = localtime (&t);
    tz = mutt_local_tz (t);
  }
  else
  {
    l = gmtime (&t);
  }

-Kevin
Details
Message ID
<YJ7zX50AooHArQEH@gpanders.com>
In-Reply-To
<YJ7x5bxCpdMj5X7W@afu.lan> (view parent)
DKIM signature
missing
Download raw message
On Fri, 14 May 2021 14:55 -0700, Kevin J. McCarthy wrote:
>I think this is okay.  Just a minor formatting nitpick below:

No problem, I'll update and send the v2 right now.

[PATCH v2] Add local_date_header option

Details
Message ID
<20210514220511.75501-1-greg@gpanders.com>
In-Reply-To
<20210514210541.74405-1-greg@gpanders.com> (view parent)
DKIM signature
missing
Download raw message
Patch: +15 -2
Add an option to convert the date used in the Date header into the local
(sender's) timezone. This is the current behavior and the option
defaults to true. Unsetting this option causes the date in the Date
header to be formatted using the GMT timezone.

This option is useful for privacy-sensitive users who may not wish to
divulge their sending timezone.
---

I made the requested formatting change and I also just initialized `l` 
with gmtime(&t) which removes the `else` branch entirely. Let me know if 
you prefer it the other way and I'll switch it back.

 init.h    |  6 ++++++
 mutt.h    |  1 +
 sendlib.c | 10 ++++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/init.h b/init.h
index 7590b315..acc7d8b2 100644
--- a/init.h
+++ b/init.h
@@ -1954,6 +1954,12 @@ struct option_t MuttVars[] = {
  ** from your spool mailbox to your $$mbox mailbox, or as a result of
  ** a ``$mbox-hook'' command.
  */
  { "local_date_header", DT_BOOL, R_NONE, {.l=OPTLOCALDATEHEADER}, {.l=1} },
  /*
  ** .pp
  ** If \fIset\fP, convert the date in the Date header of sent emails into local
  ** (sender's) timezone.
  */
  { "mail_check",	DT_NUM,  R_NONE, {.p=&BuffyTimeout}, {.l=5} },
  /*
  ** .pp
diff --git a/mutt.h b/mutt.h
index b7f9d234..88b71da5 100644
--- a/mutt.h
+++ b/mutt.h
@@ -480,6 +480,7 @@ enum
  OPTINCLUDEENCRYPTED,
  OPTINCLUDEONLYFIRST,
  OPTKEEPFLAGGED,
  OPTLOCALDATEHEADER,
  OPTMUTTLISPINLINEEVAL,
  OPTMAILCAPSANITIZE,
  OPTMAILCHECKRECENT,
diff --git a/sendlib.c b/sendlib.c
index 36264aa0..77ff044f 100644
--- a/sendlib.c
+++ b/sendlib.c
@@ -1759,8 +1759,14 @@ BODY *mutt_remove_multipart_alternative (BODY *b)
void mutt_make_date (BUFFER *s)
{
  time_t t = time (NULL);
  struct tm *l = localtime (&t);
  time_t tz = mutt_local_tz (t);
  struct tm *l = gmtime (&t);
  time_t tz = 0;

  if (option (OPTLOCALDATEHEADER))
  {
    l = localtime (&t);
    tz = mutt_local_tz (t);
  }

  tz /= 60;

-- 
2.31.1

Re: [PATCH v2] Add local_date_header option

Details
Message ID
<YJ74MhdkOaVBeanQ@afu.lan>
In-Reply-To
<20210514220511.75501-1-greg@gpanders.com> (view parent)
DKIM signature
missing
Download raw message
On Fri, May 14, 2021 at 04:05:12PM -0600, Gregory Anders wrote:
>I made the requested formatting change and I also just initialized `l`
>with gmtime(&t) which removes the `else` branch entirely. Let me know if
>you prefer it the other way and I'll switch it back.

Hi Gregory,

I think it's better to have the else branch.  Most people will leave the 
option set, so performing the gmtime() syscall in advance is a waste 
(albeit a tiny one).

-Kevin

Re: [PATCH v2] Add local_date_header option

Details
Message ID
<B29E782A-47F9-4A62-AB32-F11F94C0880E@gpanders.com>
In-Reply-To
<YJ74MhdkOaVBeanQ@afu.lan> (view parent)
DKIM signature
missing
Download raw message
> On May 14, 2021, at 4:22 PM, Kevin J. McCarthy <kevin@8t8.us> wrote:
> 
> On Fri, May 14, 2021 at 04:05:12PM -0600, Gregory Anders wrote:
>> I made the requested formatting change and I also just initialized `l`
>> with gmtime(&t) which removes the `else` branch entirely. Let me know if
>> you prefer it the other way and I'll switch it back.
> 
> Hi Gregory,
> 
> I think it's better to have the else branch.  Most people will leave the option set, so performing the gmtime() syscall in advance is a waste (albeit a tiny one).
> 
> -Kevin

Good call. I’m away from home right now but I’ll send an updated patch tonight.
Reply to thread Export thread (mbox)