From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#7337: 23.2; (require 'time) changes timezone Date: Mon, 08 Nov 2010 13:01:40 -0500 Message-ID: References: <87fwvftpdp.fsf@blah.blah> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1289240043 1296 80.91.229.12 (8 Nov 2010 18:14:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 8 Nov 2010 18:14:03 +0000 (UTC) Cc: 7337@debbugs.gnu.org To: Kevin Ryde Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 08 19:13:59 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PFWEA-0003jj-Vc for geb-bug-gnu-emacs@m.gmane.org; Mon, 08 Nov 2010 19:13:59 +0100 Original-Received: from localhost ([127.0.0.1]:56746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFWEA-0000Jw-8a for geb-bug-gnu-emacs@m.gmane.org; Mon, 08 Nov 2010 13:13:58 -0500 Original-Received: from [140.186.70.92] (port=60102 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFWDz-0000I4-OC for bug-gnu-emacs@gnu.org; Mon, 08 Nov 2010 13:13:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFWDy-0000GN-GG for bug-gnu-emacs@gnu.org; Mon, 08 Nov 2010 13:13:47 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFWDy-0000GI-Ei for bug-gnu-emacs@gnu.org; Mon, 08 Nov 2010 13:13:46 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PFVyj-00071d-Mu; Mon, 08 Nov 2010 12:58:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Nov 2010 17:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7337 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7337-submit@debbugs.gnu.org id=B7337.128923904226999 (code B ref 7337); Mon, 08 Nov 2010 17:58:01 +0000 Original-Received: (at 7337) by debbugs.gnu.org; 8 Nov 2010 17:57:22 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PFVy6-00071Q-9y for submit@debbugs.gnu.org; Mon, 08 Nov 2010 12:57:22 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PFVy4-00071L-0S for 7337@debbugs.gnu.org; Mon, 08 Nov 2010 12:57:20 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtEKAF7K10xMCpqE/2dsb2JhbAChCIECcr1UhUgEhFiNWg X-IronPort-AV: E=Sophos;i="4.58,314,1286164800"; d="scan'208";a="81942188" Original-Received: from 76-10-154-132.dsl.teksavvy.com (HELO pastel.home) ([76.10.154.132]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 08 Nov 2010 13:01:40 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 656E1A86D8; Mon, 8 Nov 2010 13:01:40 -0500 (EST) In-Reply-To: <87fwvftpdp.fsf@blah.blah> (Kevin Ryde's message of "Sat, 06 Nov 2010 08:46:42 +1100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 08 Nov 2010 12:58:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:41435 Archived-At: > Doing a (require 'time) changes the `current-time-zone' to the system > default per a (set-time-zone-rule nil). I think that loading a .el > shouldn't change the zone. The effect can be seen from "emacs -Q" > (let (before after) > (set-time-zone-rule "ABC+1") > (setq before (current-time-zone)) > (require 'time) > (setq after (current-time-zone)) > (list (car before) (car after))) > => (-3600 39600) > where I expected > => (-3600 -3600) > which is what happens if evaluated a second time, since (require 'time) > is then a no-op. Indeed, that's a bug. > I suppose it comes from display-time-world-list probing whether the > Olson timezone names are known to the C library. I think it should save > and restore the existing TZ the way `add-change-log-entry' and > `time-stamp-string' do. But do those two other uses work? > For some of my own code lately I tried a macro to hide the details and > the unwind-protect a bit. Perhaps a name like with-time-zone-rule or > with-temporary-time-zone-rule would match set-time-zone-rule better than > "...-TZ". > (defmacro xtide-with-TZ (tz &rest body) > "Run BODY with `set-time-zone-rule' temporarily to TZ. > The current timezone (per `getenv' \"TZ\") is restored by an > `unwind-protect'." > (declare (indent 1)) > `(let ((xtide-with-TZ--old (getenv "TZ"))) > (set-time-zone-rule ,tz) > (unwind-protect > (progn ,@body) > (set-time-zone-rule xtide-with-TZ--old)))) And similar does this code work for you? In my tests, (getenv "TZ") just always returns nil. So it seems we'd need to add a new function time-zone-rule to get the current time-zone rule. Or else we could make set-time-zone-rule return the previous time-zone rule. Stefan