From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ashish.is@lostca.se (Ashish SHUKLA) Newsgroups: gmane.emacs.bugs Subject: bug#19874: 25.0.50; encode-time not working as expected Date: Thu, 26 Feb 2015 05:54:19 +0530 Organization: Lost Case Message-ID: <86sidta5ak.fsf@chateau.d.if> References: <54EE0959.5080901@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1424910328 9584 80.91.229.3 (26 Feb 2015 00:25:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 26 Feb 2015 00:25:28 +0000 (UTC) Cc: 19874@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 26 01:25:20 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YQmGO-0008VC-Lb for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Feb 2015 01:25:12 +0100 Original-Received: from localhost ([::1]:56855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQmGN-0003hU-QH for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Feb 2015 19:25:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQmGI-0003bK-Pt for bug-gnu-emacs@gnu.org; Wed, 25 Feb 2015 19:25:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQmGE-0004Dc-Il for bug-gnu-emacs@gnu.org; Wed, 25 Feb 2015 19:25:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQmGE-0004DB-Bs for bug-gnu-emacs@gnu.org; Wed, 25 Feb 2015 19:25:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YQmGD-0000Mn-P9 for bug-gnu-emacs@gnu.org; Wed, 25 Feb 2015 19:25:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: ashish.is@lostca.se (Ashish SHUKLA) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Feb 2015 00:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19874 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19874-submit@debbugs.gnu.org id=B19874.14249102751373 (code B ref 19874); Thu, 26 Feb 2015 00:25:01 +0000 Original-Received: (at 19874) by debbugs.gnu.org; 26 Feb 2015 00:24:35 +0000 Original-Received: from localhost ([127.0.0.1]:58113 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YQmFm-0000M3-Gb for submit@debbugs.gnu.org; Wed, 25 Feb 2015 19:24:35 -0500 Original-Received: from aloka.lostca.se ([178.63.46.202]:25046 ident=having) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YQmFj-0000Ls-DG for 19874@debbugs.gnu.org; Wed, 25 Feb 2015 19:24:32 -0500 Original-Received: from aloka.lostca.se (aloka [127.0.0.1]) by aloka.lostca.se (Postfix) with ESMTP id 8E55057A; Thu, 26 Feb 2015 00:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=lostca.se; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=howrah; bh=j6CNcYcAe4kipCD75XaR3B8Uh58=; b=LX8D 5hIFvUSOTHE3UHIiKyqb4AvvzIgXJs5Q9qKKc0uuq2q6iJUf05nLxOnmHNfMyFes BM99U7+gkqicljXg1gxO1faCZuA3EPK98UzRY8BoGe9PDPXO0vfw6qX1YA2dbC6l oZyLrWpBp2p4Y8juNROJkiWvNXwEFBjTZKQ0bXA= Original-Received: from chateau.d.if (aloka [IPv6:::1]) by aloka.lostca.se (Postfix) with ESMTPSA id 986B4579; Thu, 26 Feb 2015 00:24:28 +0000 (UTC) Original-Received: from chateau.d.if (chateau.d.if [IPv6:::1]) by chateau.d.if (OpenSMTPD) with ESMTP id 52702f86; Thu, 26 Feb 2015 05:54:25 +0530 (IST) X-Face: )vGQ9yK7Y$Flebu1C>(B\gYBm)[$zfKM+p&TT[[JWl6:]S>cc$%-z7-`46Zf0B*syL.C]oCq[upTG~zuS0.$"_%)|Q@$hA=9{3l{%u^h3jJ^Zl; t7 X-Uptime: 5:29AM up 1:26, 8 users, load averages: 0.07, 0.24, 0.23 X-Operating-System: FreeBSD/FreeBSD 10.1-RELEASE-p6/amd64 X-OpenPGP-Fingerprint: F682 CDCC 39DC 0FEA E116 20B6 C746 CFA9 E74F A4B0 X-Attribution: =?UTF-8?Q?=E0=A4=86=E0=A4=B6=E0=A5=80=E0=A4=B7?= Organisation: Lost Case X-Hashcash: 1:20:150225:19874@debbugs.gnu.org::ReF0sZ39C32IFVqx:000000000000000000000000000000000000000008Q7 X-Hashcash: 1:20:150225:eggert@cs.ucla.edu::ghhytnJOusYstWMJ:00000000000000000000000000000000000000000001C78 In-Reply-To: <54EE0959.5080901@cs.ucla.edu> (Paul Eggert's message of "Wed, 25 Feb 2015 09:41:45 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (amd64-portbld-freebsd10.1) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEWpqal/f39tbW1jY2Md HR2goKCenp6UlJROTk7////9/f35+fnT09ORJdieAAACVklEQVQ4jXXUP2vbQBQA8AvUTkgz5OzY Z0iGWhpS6BSrkECn0mvx0MEJ6AjtYrfoBCVDlD8naJYmNlRfwZq8+mkKlIZaGpJSYmP7Q/XkJDrJ Td8i/H68u3vHPaPufwLdf32AMA4A6GcAgvAamY1pOJiDIFqicTwLswDhfr3uxfFtkAY/GFHPMwzD 8zpnACmIOnE6js7rQb+v4NJrG9od0C+QgpHMy5jBewV+UDSMWiw1Y4fWfyV7+NGFzDsYa3pth9LJ Q4XvXxFHcJRvHOmygn5NAEabnDcQQguarnfoiwSCJ99jmKKcphsZONmWsDK9Ro7cvZOCtQdg8nje egLhc2LNlkLmsezzTFUUy5w18ocox/f0LaLgJy0zO75zk+9pp85GAj36xjqhdI0y3tq2m4dqqcWX zQWBTz8L1irvolXV4J+3q7eCDgVnttjNq6X8H+9KOZsuNk1uCzx8pSp+E9HImfJOTLdcGqo+YKnG EIovizkEn48V7BO+ch2DXcD4ENSpWiU+q8hjjbgTBZCXnZtyj0Ws4Q1Q0B2WXFtYZo65Bbyeeldw RS6qFueM80LlLA29YlVwGRYvFD+kwI/0O+A2PlpOP9GwslUVciHuYGechuBTp922YiDZCrghTknm XSyOM+D3aoRZlo0Jb42zY7DN4p2x4AeZ+QAYutx1sHwTHzMT5cMNduQ9yW3GczN4KZ86kb0c9O8T yXDeFqpl2fryPEAYGXIlezAPXYh2NgVr/gvdoHIuDwuPwOhcWE8f8mmICq41eATkn8x0kuRTIKcB wE9+/QUtiiAnYcaN7wAAAABJRU5ErkJggg== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:99826 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, 25 Feb 2015 09:41:45 -0800, Paul Eggert said: | Thanks for the bug report. My guess is that there's an | incompatibility with FreeBSD 10.1 amd64 mktime. I can't reproduce the | problem on FreeBSD 9.1 x86. | Please try the attached patch, just for debugging, and then run the | following one-line shell command: | src/emacs -Q -batch -eval '(progn (setenv "TZ" "Asia/Kolkata") (print | (encode-time 44 42 6 15 2 2015 0 nil 0)))' | What output do you get? Here's what I get on Fedora 21 x86-64, which see= ms correct: | oldtz=3DAsia/Kolkata tz=3DXXX-0:00:00 oldTZ=3DAsia/Kolkata TZ=3DXXX-0:00:= 00 | 2015-02-15 06:42:44 -1 -> 2015-02-15 06:42:44 0 =3D 1423982564 | Assuming you get different output, can you debug Emacs with GDB to | send us more details about what's going wrong? If not, can you give | me access to a FreeBSD 10.1 amd64 machine like yours? Hi, When I looked into this before filing this bug report, from what I noticed that it's not using libc's `mktime' function, unlike what you seem to indicate. I'm not sure quite why it's doing that when libc provided mktime works just fine, as evident by output of attached program: =2D-8<---------------cut here---------------start------------->8--- % ./gmtime Staying at localtime zone Time (in seconds): 1423962764 Updated environment Switching to UTC Time (in seconds): 1423982564 Didn't update environment Switching to UTC+1 Time (in seconds): 1423978964 Didn't update environment Switching to UTC+3 Time (in seconds): 1423971764 =2D-8<---------------cut here---------------end--------------->8--- =2D-8<---------------cut here---------------start------------->8--- >>> print gmtime(1423962764) time.struct_time(tm_year=3D2015, tm_mon=3D2, tm_mday=3D15, tm_hour=3D1, tm_= min=3D12, tm_sec=3D44, tm_wday=3D6, tm_yday=3D46, tm_isdst=3D0) >>> print gmtime(1423982564) time.struct_time(tm_year=3D2015, tm_mon=3D2, tm_mday=3D15, tm_hour=3D6, tm_= min=3D42, tm_sec=3D44, tm_wday=3D6, tm_yday=3D46, tm_isdst=3D0) >>> print gmtime(1423978964) time.struct_time(tm_year=3D2015, tm_mon=3D2, tm_mday=3D15, tm_hour=3D5, tm_= min=3D42, tm_sec=3D44, tm_wday=3D6, tm_yday=3D46, tm_isdst=3D0) >>> print gmtime(1423971764) time.struct_time(tm_year=3D2015, tm_mon=3D2, tm_mday=3D15, tm_hour=3D3, tm_= min=3D42, tm_sec=3D44, tm_wday=3D6, tm_yday=3D46, tm_isdst=3D0) =2D-8<---------------cut here---------------end--------------->8--- The built-in mktime implementation (__mktime_internal) in Emacs sources don= 't seem to take into account timezone offsets. I might be completely wrong her= e, but the code seemed to be doing it. I'll get back to you with the output of your command-line from patched Emacs in few, but the results of my past investigation were handy so I've attached them. HTH =2D-=20 Ashish SHUKLA =E2=80=9C"Intellectual Property" is nowhere near as valuable as "Intellect"= =E2=80=9D ("Ion-Mihai Tetcu") Sent from my Emacs --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=gmtime.c Content-Description: gmtime.c #include #include #include #include #define BUFSIZE 256 void settz(const char* tz) { static char *tzvalbuf; static size_t tzvalbufsize; if( tzvalbufsize <= 3 + strlen(tz)) { tzvalbuf = malloc(tzvalbufsize = BUFSIZE); snprintf( tzvalbuf, BUFSIZE, "TZ=%s", tz ); putenv( tzvalbuf ); puts( "Updated environment" ); } else { puts( "Didn't update environment" ); snprintf( tzvalbuf, BUFSIZE, "TZ=%s", tz ); } tzset(); } int main() { struct tm t = { .tm_sec = 44, .tm_min = 42, .tm_hour = 6, .tm_mday = 15, .tm_mon = 2 - 1, .tm_year = 2015 - 1900, .tm_isdst = -1, }; time_t val; puts( "Staying at localtime zone" ); val = mktime( &t ); printf( "Time (in seconds): %ld\n", val ); settz( "TZ=XXX-0:00:00" ); puts( "Switching to UTC" ); val = mktime( &t ); printf( "Time (in seconds): %ld\n", val ); settz( "TZ=XXX-1:00:00" ); puts( "Switching to UTC+1" ); val = mktime( &t ); printf( "Time (in seconds): %ld\n", val ); settz( "TZ=XXX-3:00:00" ); puts( "Switching to UTC+3" ); val = mktime( &t ); printf( "Time (in seconds): %ld\n", val ); return 0; } --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCgAGBQJU7me0AAoJEMdGz6nnT6SwEmYP/3aYc/zE8UUVU8oDtVkfkZhE LV8rld5wb7EbAJedZKcgtD5lOh7W3ZfR1V8T5ifDCPEFjgy4CSIAFpDhIFVxz+++ RtlkF8UPnO+DJvg7nTVAW2J2RRw9XmYBWe88z4OweRa8SZYHcoGDzabLHaEo1Tae PvA/4yYch29wbYGWsRT7swNQ5Tza3839Kdbrcz2zyzu4VN1BZ+UbC+ZJj9jBAH6s XaQyWAt2RzDxZ71UAk5R2JEx7Q6HhhTGjjQTAkY99PNvHbjsS4rnXuF5NWrJw09r jpaezK/xFyh6YTQbxesAk7PcwyX/J408bJrPnxZa8T1JIYWsg/TPOmGMwXKvURRE 5DbC031qGiBX43pjKaPV1vuqm8gT64NVECe6ZBrRHFEzw9BalobAjXrHySJ15fUu iqOagMGhshOeKkh+n2xqcNzcpB3OLHt8wGQhvRhcq9t0nOq+De4EjdP2cdZ0QSyk 2JMMXyjUq9j+ZE1xRcywXvyttiM8VeAWk9D2N9h6pMrnt5WuvWQeg2PyilEAs3Fw 2ci7+45PqqAuKuCz05bj1EARWxReGTgk8pVHXu+u+GZSvuWAexFPALDTTceRxgRN vr8rxgwZ4zP3Ve3EU1ccVX05rYGWAlPWB0WMtTnsQQy/dINWIrrKOeiXWQLT19ft Dms/dJY7ThBw7hyjKQtd =9WLO -----END PGP SIGNATURE----- --==-=-=--