On Sun, 07 Nov 2021 03:24:09 +0100, Steffen Nurpmeso
<stef...@sdaoden.eu> wrote:

> Hello Andrea!
> 
> Steffen Nurpmeso wrote in
>  <20211105195037.kis5f%stef...@sdaoden.eu>:
>  |a.bia...@tiscali.it wrote in
>  | <20211105160443.514b1f69@alice.paese.meraviglie>:
>  | ...
>  ||Minimal code to reproduce the issue:
>  ||
>  ||root@darkstar:~# rm -f ~/dead.letter && TZ=Europe/Dublin mailx -S
>  ||mta=no-thank-you root < /dev/null; cat ~/dead.letter
>   ...
>  ||I am in the process of evaluating different approaches to solve
> this ||bug in a portable way (e.g. without relying on non-standard
> extensions ||like tm->tm_gmtoff, strftime's "%z" or
> timelocal()/gmtime()).
> 
> I went tm_gmtoff to use it if available.
> I will look in more detail on Monday, it is .. very late.
> The .tm_gmtoff usage is not yet correct.
> 
> However, this will be in v14.9.23 that will be release in about
> two weeks, thanks again for reporting this issue, Andrea!
> (You may then do "TZ=Europe/Dublin mailx -Smta=test X </dev/null".)

Thanks Steffen.

You can mention my name, no problem. I was about to put together a
patch for myself and share it upstream because that's the Slackware
way :)

tm_gmtoff seems like the easiest way. If you're interested in
portability, the only *portable* way of finding the offset from UTC
that I've found is:

   struct tm l,g;
   g = *gmtime(&t);
   l = *localtime(&t);

and work out the difference between g and l by checking the members
(e.g. normalizing to either number of minutes) with something like:

  diff = (l->tm_sec-g->tm_sec)/60
  +(l->tm_min-g->tm_min)
  +(l->tm_hour-g->tm_hour)*60
  /* + compensate for day/month/year difference */

I'm happy to put some code together if you want. Or test a patch, if you
prefer.

Andrea.

Reply via email to