Subject: bug#9794: 24.0.90; `format-time-string' no good for %Z

From: Eli Zaretskii <[email-masked]>
Date: Thu, 20 Oct 2011 11:24:24 +0200

> Date: Thu, 20 Oct 2011 00:48:02 -0700
> From: Paul Eggert <[email-masked]>
> CC: Jason Rumney <[email-masked]>, [email-masked], 
>  [email-masked]
> 
>     Michael Schierl reported the current-time-zone issue to RMS in 2007; see
>     <http://lists.gnu.org/archive/html/emacs-devel/2007-06/msg00334.html>.
>     But somehow the light bulb didn't go off, and current-time-zone
>     wasn't fixed.  Instead a workaround was installed, which basically
>     said "On Windows, don't ever generate time zone names, because
>     they might contain non-ASCII characters."

That's not a fair description of what was done.  In response to my
question of whether this was too drastic a measure, Jason explained
the real reason for the change he did:

  Non-ASCII is a side issue, and treating it as the main issue is what
  caused us to install an incorrect fix originally.

  The original issue reported a number of years ago, was that the timezone
  names for the Japanese locale on Windows are not RFC 822 compliant. So
  we suppressed them in certain conditions, but in fact, the timezone
  names are not RFC 822 compliant in most locales on Windows. Unless we
  use a lookup table to figure out which names are RFC compliant and which
  aren't, then I don't see a way we can leave them enabled.

>     Any code that assumes that (format-time-string "%Z") must generate
>     an RFC822 zone is making an unwarranted assumption and should be
>     fixed.

Fixed how?  Given some arbitrary string, how can Lisp code check
whether it is or isn't compliant?  Non-ASCII characters are easy to
check, but what about time zones that include only ASCII characters?

And anyway, if all bets are off about the strings returned by
current-time-zone, then what exactly is its contract?

If we are going to require Lisp code to check the values and reject
non-compliant ones, we should at the very least provide a utility
function to do that correctly.  Can you suggest such a function?

>            I did a quick scan for such code in Emacs and didn't find
>     any.  Perhaps there's some out-of-Emacs Lisp code that's making
>     the assumption, but if so, that code needs to be fixed because
>     in general it does not work and has never worked.

Jason, can you point out which package(s) needed an RFC822-compliant
time zone name?  In the mail exchange I found, you just say

  [...] since the result of current-time-zone is used for mail
  headers, where non-ASCII characters are not allowed, and the POSIX
  timezone names are expected [...]