From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Friedrich Delgado Newsgroups: gmane.emacs.bugs Subject: bug#24716: 24.3; time-subtract result is one hour off Date: Thu, 20 Oct 2016 09:27:02 +0200 Organization: DFN-CERT Services GmbH Message-ID: <20161020072702.GA20251@rosita.dfn-cert.de> References: <20161017093904.GA29914@rosita.dfn-cert.de> <87insom7tc.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1476948603 4118 195.159.176.226 (20 Oct 2016 07:30:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 20 Oct 2016 07:30:03 +0000 (UTC) Cc: 24716@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 20 09:29:54 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bx7n9-0005gp-NB for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Oct 2016 09:29:31 +0200 Original-Received: from localhost ([::1]:52914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bx7nB-0006f2-JD for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Oct 2016 03:29:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bx7lm-0005oU-M3 for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 03:28:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bx7li-0001Gu-KI for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 03:28:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34093) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bx7li-0001Gp-Gu for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 03:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bx7li-0000tx-93 for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 03:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Friedrich Delgado Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 Oct 2016 07:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24716 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 24716-submit@debbugs.gnu.org id=B24716.14769484313388 (code B ref 24716); Thu, 20 Oct 2016 07:28:02 +0000 Original-Received: (at 24716) by debbugs.gnu.org; 20 Oct 2016 07:27:11 +0000 Original-Received: from localhost ([127.0.0.1]:40280 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bx7ks-0000sZ-On for submit@debbugs.gnu.org; Thu, 20 Oct 2016 03:27:10 -0400 Original-Received: from mail1.dfn-cert.de ([193.174.13.200]:60642) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bx7kr-0000sL-Nn for 24716@debbugs.gnu.org; Thu, 20 Oct 2016 03:27:10 -0400 Original-Received: by rosita.dfn-cert.de (Postfix, from userid 565) id 4C411BF; Thu, 20 Oct 2016 09:27:02 +0200 (CEST) Content-Disposition: inline In-Reply-To: <87insom7tc.fsf@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:124713 Archived-At: Ah, thanks for explaining this! I had the suspicion that I might have overlooked something, that's why I tried to get feedback on #emacs first before submitting this as a bug (unfortunately there weren't many people available at that time). I simply didn't think of checking the timezone and of course I didn't read the full documentation of these functions. :) Sorry for the noise! Kind regards Friedel Tino Calancha: %<--- %<--- %<--- %<--- %<--- > Friedrich Delgado writes: > > Thank you for your report. > I don't see nothing wrong. See below. > > In emacs 24.3, I found that time-subtract returns a time difference > > that is one hour to large. The same appears to be valid in 25.1. > > > > Evaluate the following: > > > > (decode-time (time-subtract (encode-time 0 10 18 10 10 2016 nil 3600) (encode-time 0 40 8 10 10 2016 nil 3600))) > > > > (decode-time (time-add (encode-time 0 40 8 10 10 2016 nil 3600) (time-subtract (encode-time 0 10 18 10 10 2016 nil 3600) (encode-time 0 40 8 10 10 2016 nil 3600)))) > > > > Results are: > > (0 30 10 1 1 1970 4 nil 3600) > > > > for the first expression and > > > > (0 10 19 10 10 2016 1 t 7200) > Both results are correct. > > > I'd expect a list starting with (0 30 9 ...) for the first expression > The list would start (0 30 9 ...) if the time zone correspond to > Greenwich meridian, then you would get the equivalent value: > (0 30 9 1 1 1970 4 nil 0). > > (because the duration from 8:40 in the morning to 18:10 in the evening > > is 9 hours and 30 minutes, NOT 10 hours and 30 minutes) > For time zone 3600, the origin of the time is: > (0 0 1 1 1 1970 4 nil 3600). > > and the second > > list to start with 0 10 18 (so we arrive back at the later time if we > > add the difference to the sooner time). > Indeed you have arrived back to the sooner time: it starts > (0 10 19 ... 7200) > instead of > (0 10 18 ... 3600) > just because it is expressed in your time zone, i.e., +02:00, > instead of +01:00, but it's the same absolute time. > > > chipping on #emacs tells me he gets a functionally equivalent result > > on a more recent emacs version: > > > > chipping > TauPan: what is your result for the time-subtract version? I get (0 0 17 1 1 1970 4 nil 27000) on emacs 25.1.1 > > > > Since (format-time-string "%H:%M" (encode-time 0 0 17 1 1 1970 4 nil > > 27000)) is "10:30" they're basically the same (wrong) result. > The value from 25.1.1 > (0 0 17 1 1 1970 4 nil 27000) > is also correct: 27000 s = 7.5 h, 3600 s = 1 h > Then, to translate > (0 30 10 1 1 1970 4 nil 3600) > to 27000 time zone we need to add 7.5 - 1 = 6.5 h > > 10:30 + 6.5h --> 17:00 > > Try to pass t as third argument to display the universal time: > (format-time-string "%H:%M %z" (encode-time 0 0 17 1 1 1970 4 nil 27000) t) > => "09:30 +0000" %<--- %<--- %<--- %<--- %<--- %<--- -- Dipl.-Inform Friedrich Delgado (Projekt- und Entwicklungsteam) DFN-CERT Services GmbH, https://www.dfn-cert.de/ Sitz/Register: Hamburg, AG Hamburg, HRB 88805, Ust-IdNr.: DE 232129737 Sachsenstraße 5, 20097 Hamburg/Germany, CEO: Dr. Klaus-Peter Kossakowski