This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: setting TZ is harmful


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,
> /etc/profile.d/tzset.csh).
> 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:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
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
MSK+3+0600
$ TZ=Asia/Omsk   date -d2017-01-01 +%Z%z
+06+0600
$ TZ='<MSK+3>-6' date -d2017-07-01 +%Z%z
MSK+3+0600
$ TZ=Asia/Omsk   date -d2017-07-01 +%Z%z
+06+0600

Now they have quoting, maybe they will consider allowing other
characters from the current locale e.g. UTF-8 <МСК+3>, which works with
Cygwin:

$ TZ='<МСК+3>-6' date -d2017-01-01 +%Z%z
МСК+3+0600
$ TZ='<МСК+3>-6' date -d2017-01-01 +%Z%z | cat -A
M-PM-^\M-PM-!M-PM-^Z+3+0600$

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]