This is the mail archive of the
mailing list for the Cygwin project.
Re: setting TZ is harmful
- From: Brian Inglis <Brian dot Inglis at SystematicSw dot ab dot ca>
- To: cygwin at cygwin dot com
- Date: Tue, 6 Jun 2017 10:51:43 -0600
- Subject: Re: setting TZ is harmful
- Authentication-results: sourceware.org; auth=none
- References: <2397524.6dhiyKbjLM@omega>
- Reply-to: Brian dot Inglis at SystematicSw dot ab dot ca
On 2017-05-09 07:37, Bruno Haible wrote:
> Currently, all commands in a Cygwin command window are run with the TZ
> environment variable set.
> It is set by /etc/profile.d/tzset.sh (or its csh equivalent,
> Setting TZ is harmful in two ways:
> 1) When the user changes the time zone (through the Windows Control Panel) -
> for example when traveling - the programs run in the Cygwin command
> window will display a stale notion of local time. Only after the user
> closes and re-opens a new Cygwin command window, will the programs
> display local time according to the new time zone.
> 2) It causes native Windows programs (built through mingw, MSVC) to assume
> a time zone that is different from the intended one and different from
> the one that the user has set in the Windows Control Panel (see APPENDIX 1
> below). This is because in most geographies, the values of TZ (produced
> by winsup/utils/tzset.c and winsup/utils/tzmap.h) contains a slash, and
> the tzset() function in the Microsoft CRT does not understand this syntax
> - it understands only a different syntax
> https://msdn.microsoft.com/en-us/library/90s5c885.aspx .
> When TZ is not set, both Cygwin and native Windows programs take their time
> zone information from the Windows Control Panel settings. See APPENDIX 2
> below and https://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00035.html .
> What are the benefits of setting the TZ environment variable? I don't
> see any!
Windows TZ is not POSIX compliant:
which allows up to TZNAME_MAX bytes from the portable character set in
the current locale and quoting using <> which allows alphanumeric, plus,
and minus characters from that set, e.g. TZ=<MSK+3>-6 instead of Asia/Omsk:
$ TZ='<MSK+3>-6' date -d2017-01-01 +%Z%z
$ TZ=Asia/Omsk date -d2017-01-01 +%Z%z
$ TZ='<MSK+3>-6' date -d2017-07-01 +%Z%z
$ TZ=Asia/Omsk date -d2017-07-01 +%Z%z
Now they have quoting, maybe they will consider allowing other
characters from the current locale e.g. UTF-8 <МСК+3>, which works with
$ TZ='<МСК+3>-6' date -d2017-01-01 +%Z%z
$ TZ='<МСК+3>-6' date -d2017-01-01 +%Z%z | cat -A
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple