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:references :in-reply-to:content-type:content-transfer-encoding :mime-version; q=dns; s=default; b=frrCRUFI36sLMFadjNPMEoPqsnG97 cMSTDLDQoraZqz25Lgc9RR3UzbQgUiuhp1/gQNqnonL2zJDJ1SMw/6JkHijfGykB 27UZGoAEWx85VXcsqODqnZ5bM7sx6LOiG5XNp728rWyJ7V9rNwEtsCSm1N9cgYaE MlAoEQh1rvgZoM= 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:references :in-reply-to:content-type:content-transfer-encoding :mime-version; s=default; bh=fiVOK0FA0xZJ9px57lmS7skgc5o=; b=P+9 wMhb/DEYdQICZyjCEzBUl19tWj8Jn1ya8Ai0cdwDuFRB1ct8zowhfBZ0c+LTgfjC 9TRwR9y4nHCVGiyQyFM5YT6MStHbuDttDJsgfsNKGFnzB2b4xRpU+Rl82hTkb41f 2ePLt5KEhZDx69NO35DMjhumYefznY9lsVtuuIKM= 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,SPF_PASS autolearn=ham version=3.3.2 spammy=HX-DKIM:Filter, HX-DKIM:OpenDKIM, H*r:0400, Window X-HELO: esa6.dell-outbound.iphmx.com From: "Gluszczak, Glenn" X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd05.lss.emc.com v49EAHxW026259 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd05.lss.emc.com v49EAHxW026259 To: "cygwin AT cygwin DOT com" Subject: RE: setting TZ is harmful Date: Tue, 9 May 2017 14:09:53 +0000 Message-ID: <91DCAC3CB99C724EB365BB64677FBE7B1EF4F3A8@MX204CL04.corp.emc.com> References: <2397524 DOT 6dhiyKbjLM AT omega> In-Reply-To: <2397524.6dhiyKbjLM@omega> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-Sentrion-Hostname: mailusrhubprd53.lss.emc.com X-RSA-Classifications: public, GIS Solicitation X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id v49EAmmP002775 Ran into issues with TZ in the past too. ActiveState Perl is picky. I use the PST8PDT format for TZ, but could be other Window programs that won't accept that. $ TZ="" date Tue, May 9, 2017 2:02:50 PM $ TZ="America/Los_Angeles" date Tue, May 9, 2017 7:01:39 AM $ TZ="PST8PEDT" date Tue, May 9, 2017 7:01:49 AM Cygwin Perl ========= $ TZ="" perl -e "print scalar localtime(time);" Tue May 9 13:59:57 2017 $ TZ="America/Los_Angeles" perl -e "print scalar localtime(time);" Tue May 9 07:00:28 2017 $ TZ="PST8PDT" perl -e "print scalar localtime(time);" Tue May 9 07:00:45 2017 ActiveState Perl ============ $ TZ="" ./perl -e "print scalar localtime(time);" Tue May 9 07:06:06 2017 $ TZ="America/Los_Angeles" ./perl -e "print scalar localtime(time);" Tue May 9 15:06:29 2017 $ TZ="PST8PDT" ./perl -e "print scalar localtime(time);" Tue May 9 07:06:47 2017 Glenn ==================================================================== 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 -- 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