From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 25 19:22:15 2019 Received: (at submit) by debbugs.gnu.org; 25 Jun 2019 23:22:15 +0000 Received: from localhost ([127.0.0.1]:33862 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfulT-00038F-G2 for submit@debbugs.gnu.org; Tue, 25 Jun 2019 19:22:15 -0400 Received: from lists.gnu.org ([209.51.188.17]:43020) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfuZy-0002kL-Uv for submit@debbugs.gnu.org; Tue, 25 Jun 2019 19:10:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33714) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfuZx-0006tH-PL for bug-coreutils@gnu.org; Tue, 25 Jun 2019 19:10:22 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfuZw-00044D-Hb for bug-coreutils@gnu.org; Tue, 25 Jun 2019 19:10:21 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:40216) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfuZw-0003ym-5S for bug-coreutils@gnu.org; Tue, 25 Jun 2019 19:10:20 -0400 Received: by mail-pl1-x633.google.com with SMTP id a93so259462pla.7 for ; Tue, 25 Jun 2019 16:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=rEqoCF2wxlNSSQ2B1NrKPwdMs99/nyI8DZitxJdpFgo=; b=Rgb+RRmy4S1Jf3DT+5XqQCt+i/yYT30BvS35FmIEnErVAV0F4yuoiakgKXW8Tasan6 fwn+w9bHruJLKmP73yisqlHCJ79PKiJ5w0ZFbeazohfzDAZsPbwSvQ6EsvjzhoO1SsfV Ir0tWwg/RtBwkxZHMF2/D0qIVo6Kb8qFz6GxdUlBDu4peE1mIjEcgOmfVYR6aO9z8Sfs /Lio0eWvAkTdrmHyAB0ZhntIldXuZLHFZGXf7jRZk+pI1IWMhM/pdfVzgzPDEJM7FF01 0lsTeXt/SZgaEHIiOD5PNgmq/8Bt5xqb/+5D6s8X7SRZkJVtQAUQ9qT305Fl3+r/X6xK GvNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=rEqoCF2wxlNSSQ2B1NrKPwdMs99/nyI8DZitxJdpFgo=; b=OThA184BJN6bV9cUuUnErfrOEOdimbLr5mpUoSEx5cJPd3Re/P0HA7vuXowlim/XkW NSi1Mhv3c5IQncbXVLHnLzFgsmwZ0vMpk6Ao7Q7YkiKKXjKER62PPCboDBC+H2S/mnCy +GGYpXBoeZlza2Yr/uGEPyxajhubwF+Wkkol5blyiGfOQzLiUSvkjV98D/1B0lTE+VoU MHiW1UZa0TAIeu31idWVvSJVOUqCq5o3nlCQypDwVXho/BLdkTClu4ZngGVv0od31uKZ ElQgfRTPzlULS5x437ewGPDvMl4ZZtz+mgYgTtD1S/b5Al4znLrvZTUwT/SJVBWTWU8+ +fUw== X-Gm-Message-State: APjAAAU7oTF/5pug300kqhWjYjf6rE8sXKFL7AtkTdFPgRwoNodxN+5+ 00OmF3JZ7IkAItvGR8SzVcQvGUkjCyHTLpITFXjcnSZt X-Google-Smtp-Source: APXvYqxBKc+sjxWFSh/unOFLJZnl2+u56O8E5V4PcJekKZftY6ddgczKgFLb47wHmkhKDT8TsZDs6lrXRdaQgQDWHpI= X-Received: by 2002:a17:902:1004:: with SMTP id b4mr1285450pla.325.1561504218047; Tue, 25 Jun 2019 16:10:18 -0700 (PDT) MIME-Version: 1.0 From: Brian Woods Date: Tue, 25 Jun 2019 16:10:07 -0700 Message-ID: Subject: date command processes timezone differently when doing math To: bug-coreutils@gnu.org Content-Type: multipart/alternative; boundary="0000000000003b6c31058c2e08d8" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::633 X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 25 Jun 2019 19:22:13 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --0000000000003b6c31058c2e08d8 Content-Type: text/plain; charset="UTF-8" When doing a math operation to a date command it appear to process the timezone differently. The system is Ubuntu 18.04.2 LTS. Versions: coreutils/bionic,now 8.28-1ubuntu1 amd64 [installed] #echo $datNow 2019-06-25 15:21:34 #date -d "$datNow " "+%Y-%m-%d %H:%M:%S" --debug date: parsed date part: (Y-M-D) 2019-06-25 date: parsed time part: 15:21:34 date: input timezone: system default date: using specified time as starting value: '15:21:34' date: starting date/time: '(Y-M-D) 2019-06-25 15:21:34' date: '(Y-M-D) 2019-06-25 15:21:34' = 1561501294 epoch-seconds date: timezone: system default date: final: 1561501294.000000000 (epoch-seconds) date: final: (Y-M-D) 2019-06-25 22:21:34 (UTC) date: final: (Y-M-D) 2019-06-25 15:21:34 (UTC-07) 2019-06-25 15:21:34 #date -d "$datNow + 1 minute" "+%Y-%m-%d %H:%M:%S" --debug date: parsed date part: (Y-M-D) 2019-06-25 date: parsed time part: 15:21:34 UTC+01 date: parsed relative part: +1 minutes date: input timezone: parsed date/time string (+01) date: using specified time as starting value: '15:21:34' date: starting date/time: '(Y-M-D) 2019-06-25 15:21:34 TZ=+01' date: '(Y-M-D) 2019-06-25 15:21:34 TZ=+01' = 1561472494 epoch-seconds date: after time adjustment (+0 hours, +1 minutes, +0 seconds, +0 ns), date: new time = 1561472554 epoch-seconds date: timezone: system default date: final: 1561472554.000000000 (epoch-seconds) date: final: (Y-M-D) 2019-06-25 14:22:34 (UTC) date: final: (Y-M-D) 2019-06-25 07:22:34 (UTC-07) --0000000000003b6c31058c2e08d8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
When doing a math operation to a date command it appear to= process the timezone differently.

The system is Ub= untu 18.04.2 LTS.
Versions: coreutils/bionic,now 8.28-1ubuntu= 1 amd64 [installed]

#echo $datNow
2019-06= -25 15:21:34

#date -d "$datNow " &qu= ot;+%Y-%m-%d %H:%M:%S" --debug
date: parsed date part: (Y-M-D) 2019= -06-25
date: parsed time part: 15:21:34
date: input timezone: system = default
date: using specified time as starting value: '15:21:34'=
date: starting date/time: '(Y-M-D) 2019-06-25 15:21:34'
date= : '(Y-M-D) 2019-06-25 15:21:34' =3D 1561501294 epoch-seconds
dat= e: timezone: system default
date: final: 1561501294.000000000 (epoch-sec= onds)
date: final: (Y-M-D) 2019-06-25 22:21:34 (UTC)
date: final: (Y-= M-D) 2019-06-25 15:21:34 (UTC-07)
2019-06-25 15:21:34

=
#date -d "$datNow + 1 minute" "+%Y-%m-%d %H:%M:%S= " --debug
date: parsed date part: (Y-M-D) 2019-06-25
date: parse= d time part: 15:21:34 UTC+01
date: parsed relative part: +1 minutes
d= ate: input timezone: parsed date/time string (+01)
date: using specified= time as starting value: '15:21:34'
date: starting date/time: &#= 39;(Y-M-D) 2019-06-25 15:21:34 TZ=3D+01'
date: '(Y-M-D) 2019-06-= 25 15:21:34 TZ=3D+01' =3D 1561472494 epoch-seconds
date: after time = adjustment (+0 hours, +1 minutes, +0 seconds, +0 ns),
date: =C2=A0 =C2= =A0 new time =3D 1561472554 epoch-seconds
date: timezone: system default=
date: final: 1561472554.000000000 (epoch-seconds)
date: final: (Y-M-= D) 2019-06-25 14:22:34 (UTC)
date: final: (Y-M-D) 2019-06-25 07:22:34 (U= TC-07)


--0000000000003b6c31058c2e08d8-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 26 10:37:41 2019 Received: (at 36383) by debbugs.gnu.org; 26 Jun 2019 14:37:41 +0000 Received: from localhost ([127.0.0.1]:36688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg93N-0007Fi-4j for submit@debbugs.gnu.org; Wed, 26 Jun 2019 10:37:41 -0400 Received: from mail-pf1-f180.google.com ([209.85.210.180]:45140) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hg93L-0007FQ-Di; Wed, 26 Jun 2019 10:37:40 -0400 Received: by mail-pf1-f180.google.com with SMTP id r1so1453546pfq.12; Wed, 26 Jun 2019 07:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=q4Myk9aKWm6ktrs9Lbn0pqQXL1VYKmAuCD1wfVt7v7A=; b=gtmv58l6BdV7p9kkukHYjpLnAlHDYNP6qq9Dlq9TjMzRIs0vf9zRu/SOUT3sVmWUFO HvK+CAs58crATLO81qqIbFeYfIAiyO1u75Xtyw6hJBdK43cLfYAwNPOXKmBz7IPAYgXa 16um08pUxbEd9cdy/lmfg5KnHsB90NtUen/Afx7iB1kx2Uo7WXLnaRSe1voMQIcLCpYl nm/NaLtLI/DOrp9CoR6uVSRshfDdayv6KG6TpH7XiOSotGEkWKt6hnLfXRvp5O5BhLwD 9LjACj8Lm28diWOI18LP0spvUl6SbtRazIsS8TaNLjPcUxLNwxlNW/LczjHp/mIoO6hw 5osw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=q4Myk9aKWm6ktrs9Lbn0pqQXL1VYKmAuCD1wfVt7v7A=; b=Brw7Mf+f4RL0pIjw5tq9ERYA3jajzx4ucDfMI/wu5xK+qREmEllsEmBYFCsjDf201J Xh0ElERLMIYOG5MwBZ4ujBN61+EvFycQfIQs2LbkwfwPOMliLYRENZU5YLj5Fbhvjm4Q vJp0Ahwj2ciXbZz+ACLErr94FUzQxQGukmHlEaf3UgwsXFlhmzF7bM5xNsvugSYvfifl Mmqi2m66OTQUhZwjbNZtlopehIpLt3ULc5HIPHZROCvavgx0sIzjWEsjiZWEsc1+QYtd Iq6lMrgW7ngrMwWKHkIk/o395xyKmfecOPqiEnnxBv2IhpU1HzJrHKjtuHzfYBVZd9SZ Q6xA== X-Gm-Message-State: APjAAAXtNned1NFRsEueAzqWPcDYe5i/Ca+nU8evepraM4sQ/VVsSdhh FqGWzWhQ83bdgzhs62umX40Ryvz0 X-Google-Smtp-Source: APXvYqxCAFPlydf/HgJAMep4u3uyAo5dQKZTANtduA78nEGCLuwecjOEV4uxNXdm+HRNQft/xyiyMw== X-Received: by 2002:a63:2985:: with SMTP id p127mr3092913pgp.400.1561559852783; Wed, 26 Jun 2019 07:37:32 -0700 (PDT) Received: from tomato (moose.housegordon.com. [184.68.105.38]) by smtp.gmail.com with ESMTPSA id u97sm2152286pjb.26.2019.06.26.07.37.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2019 07:37:31 -0700 (PDT) Received: by tomato (Postfix, from userid 1000) id 08398680A50; Wed, 26 Jun 2019 08:37:30 -0600 (MDT) Date: Wed, 26 Jun 2019 08:37:29 -0600 From: Assaf Gordon To: Brian Woods Subject: Re: bug#36383: date command processes timezone differently when doing math Message-ID: <20190626143729.GC22150@tomato.moose.housegordon.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36383 Cc: 36383@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tag 36383 notabug close 36383 stop Hello, On Tue, Jun 25, 2019 at 04:10:07PM -0700, Brian Woods wrote: > When doing a math operation to a date command it appear to process the > timezone differently. [...] > > #echo $datNow > 2019-06-25 15:21:34 > > #date -d "$datNow + 1 minute" "+%Y-%m-%d %H:%M:%S" --debug > date: parsed date part: (Y-M-D) 2019-06-25 > date: parsed time part: 15:21:34 UTC+01 > date: parsed relative part: +1 minutes > date: input timezone: parsed date/time string (+01) Thank you for providing detailed examples with "--debug", makes things much easier to troubleshoot. The issue is that a time string (HH:MM:SS) followed by a plus sign and a number is *always* taken to be a time zone. Using a value other than 1 will show it more clearly: $ date -d "$datNow + 8 minutes" "+%Y-%m-%d %H:%M:%S" --debug date: parsed date part: (Y-M-D) 2019-06-25 date: parsed time part: 15:21:34 UTC+08 date: parsed relative part: +1 minutes date: input timezone: parsed date/time string (+08) The "+8" part is treated as timezone, and the remaining text ("minutes") is taken as a one-minute time adjustment. One solution is to just remove the plus sign: $ date -d "$datNow 8 minutes" "+%Y-%m-%d %H:%M:%S" --debug date: parsed date part: (Y-M-D) 2019-06-25 date: parsed time part: 15:21:34 date: parsed relative part: +8 minutes date: input timezone: system default [...] 2019-06-25 15:29:34 Another is to specify the time zone: $ date -d "$datNow +00:00 +8 minutes" "+%Y-%m-%d %H:%M:%S" --debug date: parsed date part: (Y-M-D) 2019-06-25 date: parsed time part: 15:21:34 UTC+00 date: parsed relative part: +8 minutes date: input timezone: parsed date/time string (+00) [...] 2019-06-25 09:29:34 More examples of adjusting time strings are here (your example is similar to case #1): https://lists.gnu.org/archive/html/bug-coreutils/2018-10/msg00126.html As such, I'm closing this ticket but discussion can continue by replying to this thread. regards, - assaf From unknown Sat Jun 14 14:29:12 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 25 Jul 2019 11:24:12 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator