X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-transfer-encoding:content-type; q=dns; s=default; b=hha OO4POa9YpENIHHYwfze+z+T66KU9q9TcLqlY2SVz/Zde37J5fN0tYovILo7u1998 THbz/yI8X0kQAjSr6V0/+IyKUQ6BblbevAvnI8hELQxP5MMJqwXpwyKlDDmjbH7z xaCgckmwhYknX60fAxeBCIbpV07edIq4JS/FS2mU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=default; bh=iIV2tN7+v Vhh/tAFfrGwRXtC3Pk=; b=J5bVe0d6sxdGgNBcQGa31XtyJQHmjBHAEydieYKiz bdNgejRaFq/5YZqmVswgkuy+u/D9IquoE1qgXqdb3S38rF7HQ+ElhPlvjYSTkeHh 8/E6TwTLHRcsn2DwfVTvrXI1QV1SNWKl64VIQZTBM3eD7l8BgDGpHFn6Rcxg4kNG gg= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=eur, cet, crt, traveling X-HELO: mo4-p00-ob.smtp.rzone.de X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRavM440Lyyw== X-RZG-CLASS-ID: mo00 From: Bruno Haible To: cygwin AT cygwin DOT com Subject: setting TZ is harmful Date: Tue, 09 May 2017 15:37:51 +0200 Message-ID: <2397524.6dhiyKbjLM@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-75-generic; KDE/5.18.0; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Hi, 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! ===> Please remove /etc/profile.d/tzset.{sh,csh} ! <=== Side note: An empty TZ value is equivalent to an unset TZ variable for mingw and MSVC compiled programs, but not for Cygwin programs (which interpret it as GMT). See APPENDIX 2 below. Bruno ======= APPENDIX 1: Effects of Cygwin-set TZ on programs ========= $ ./showtime-cygwin.exe now = 17286 17 157 as GMT: 2017-04-30 17:02:37 dst=0 as GMT: Sun Apr 30 17:02:37 2017 as localtime: 2017-04-30 19:02:37 dst=1 as localtime: Sun Apr 30 19:02:37 2017 tzname[0] = CET, tzname[1] = CEST $ ./showtime-mingw.exe now = 17286 17 175 as GMT: 2017-04-30 17:02:55 dst=0 as GMT: Sun Apr 30 17:02:55 2017 as localtime: 2017-04-30 18:02:55 dst=1 as localtime: Sun Apr 30 18:02:55 2017 tzname[0] = Eur, tzname[1] = ope $ ./showtime-msvc.exe now = 17286 17 234 as GMT: 2017-04-30 17:03:54 dst=0 as GMT: Sun Apr 30 17:03:54 2017 as localtime: 2017-04-30 18:03:54 dst=1 as localtime: Sun Apr 30 18:03:54 2017 tzname[0] = Eur, tzname[1] = ope ======= APPENDIX 2: Effects of unset TZ or empty TZ on programs ======= Cygwin: makes a difference $ (unset TZ; ./showtime-cygwin.exe ) now = 17292 20 3383 as GMT: 2017-05-06 20:56:23 dst=0 as GMT: Sat May 6 20:56:23 2017 as localtime: 2017-05-06 22:56:23 dst=1 as localtime: Sat May 6 22:56:23 2017 tzname[0] = WEST, tzname[1] = WEST $ TZ= ./showtime-cygwin.exe now = 17292 20 3420 as GMT: 2017-05-06 20:57:00 dst=0 as GMT: Sat May 6 20:57:00 2017 as localtime: 2017-05-06 20:57:00 dst=0 as localtime: Sat May 6 20:57:00 2017 tzname[0] = GMT, tzname[1] = mingw: no difference $ (unset TZ; ./showtime-mingw.exe ) now = 17292 20 3395 as GMT: 2017-05-06 20:56:35 dst=0 as GMT: Sat May 06 20:56:35 2017 as localtime: 2017-05-06 22:56:35 dst=1 as localtime: Sat May 06 22:56:35 2017 tzname[0] = W. Europe Standard Time, tzname[1] = W. Europe Summer Time $ TZ= ./showtime-mingw.exe now = 17292 20 3426 as GMT: 2017-05-06 20:57:06 dst=0 as GMT: Sat May 06 20:57:06 2017 as localtime: 2017-05-06 22:57:06 dst=1 as localtime: Sat May 06 22:57:06 2017 tzname[0] = W. Europe Standard Time, tzname[1] = W. Europe Summer Time msvc: no difference $ (unset TZ; ./showtime-msvc.exe ) now = 17292 20 3401 as GMT: 2017-05-06 20:56:41 dst=0 as GMT: Sat May 6 20:56:41 2017 as localtime: 2017-05-06 22:56:41 dst=1 as localtime: Sat May 6 22:56:41 2017 tzname[0] = W. Europe Standard Time, tzname[1] = W. Europe Summer Time $ TZ= ./showtime-msvc.exe now = 17292 20 3431 as GMT: 2017-05-06 20:57:11 dst=0 as GMT: Sat May 6 20:57:11 2017 as localtime: 2017-05-06 22:57:11 dst=1 as localtime: Sat May 6 22:57:11 2017 tzname[0] = W. Europe Standard Time, tzname[1] = W. Europe Summer Time -- 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