Bruno Haible wrote:
Only for Cygwin, an empty or absent TZ environment variable means GMT.
That's weird; I don't know of any other system that does that. In many systems,
an empty but set TZ means UTC0 without leap seconds; but an unset TZ typically
means "ask the file system for the time zone", e.g., /etc/localtime or something
like that. Perhaps the Cygwin folks could be talked into changing an unset TZ to
mean "ask the Windows Control Panel".
The full set of TZ values understood by MSVC CRT is not documented. (Maybe
there are more valid strings than those that fit your regexp?)
Maybe there are. However, I think the ERE captures all the values that Microsoft
documents, and this should be good enough.
How about this revised comment?
+ There are two possible kinds of such values:
+ - Traditional US time zone names, e.g. "PST8PDT",
+ - tzdata time zone names, based on geography. They contain one
+ or more slashes.
As a point of terminology, "PST8PDT" is as much of a tzdata time zone name as
"America/Los_Angeles" is. They are both implemented by consulting a file by that
name. And some of the slashless tzdata names are based on geography, e.g.,
"Singapore", "GB-Eire" (these are mostly present for backward compatibility, but
some people still use them). Perhaps it would be better to summarize things by
wording the comment something like this:
TZ values are of two kinds:
- Values supported by the Microsoft CRT, e.g., "PST+8PDT". See
<https://msdn.microsoft.com/en-us/library/90s5c885.aspx>. The documented values
of this form are matched by the POSIX extended regular expression
"^[A-Za-z]{3}[-+]?[01]?[0-9](:[0-5][0-9](:[0-5][0-9])?)?([A-Za-z]{3})?$".
- Values supported by Cygwin, e.g., "America/Los_Angeles". Typically, each of
these values corresponds to the name of a file installed somewhere on the
system. However, some of these values are analyzed programmatically based on
rules specified by POSIX, e.g., "PST8PDT,M3.2.0,M11.1.0"; see
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03>.
The two kinds of TZ values overlap, e.g., "PST8PDT" is valid in both
implementations. However, most TZ values supported by Cygwin do not work with
the Microsoft CRT, which silently uses UTC when given such values. In practice
most of these troublesome TZ values contain '/', and no TZ value supported by
the Microsoft CRT contains '/', so as a heuristic neutralize any TZ value
containing '/'. For the Microsoft CRT, an absent or empty TZ means the time zone
that the user has set in the Windows Control Panel.
+ neutralize it. For the Microsoft CRT, an absent of empty TZ means
absent of -> absent or