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/ (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
> .
> 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 .
> 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:
Unsubscribe info:

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