From unknown Fri Jun 20 07:10:21 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#12162 <12162@debbugs.gnu.org> To: bug#12162 <12162@debbugs.gnu.org> Subject: Status: [date] wrong time returned from provided relative date description Reply-To: bug#12162 <12162@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:10:21 +0000 retitle 12162 [date] wrong time returned from provided relative date descri= ption reassign 12162 coreutils submitter 12162 Andris Pavenis severity 12162 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 09 03:46:34 2012 Received: (at submit) by debbugs.gnu.org; 9 Aug 2012 07:46:34 +0000 Received: from localhost ([127.0.0.1]:43639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzNRx-0007xp-N2 for submit@debbugs.gnu.org; Thu, 09 Aug 2012 03:46:34 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52322) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzNFO-0007ea-S0 for submit@debbugs.gnu.org; Thu, 09 Aug 2012 03:33:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzN7V-0007RJ-H0 for submit@debbugs.gnu.org; Thu, 09 Aug 2012 03:25:26 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:53783) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzN7V-0007RF-DX for submit@debbugs.gnu.org; Thu, 09 Aug 2012 03:25:25 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzN7U-0001Zs-Dt for bug-coreutils@gnu.org; Thu, 09 Aug 2012 03:25:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzN7T-0007Qw-Hl for bug-coreutils@gnu.org; Thu, 09 Aug 2012 03:25:24 -0400 Received: from mgw1.ipnetworks.fi ([88.148.165.20]:49155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzN7T-0007QT-7Y for bug-coreutils@gnu.org; Thu, 09 Aug 2012 03:25:23 -0400 Received: (qmail 7701 invoked from network); 9 Aug 2012 07:25:08 -0000 Received: from unknown (HELO callisto.ipnetworks.fi) (apavenis@[192.168.152.176]) (envelope-sender ) by mgw1.ipnetworks.fi (qmail-ldap-1.03) with SMTP for ; 9 Aug 2012 07:25:08 -0000 Message-ID: <502365DA.4080802@iki.fi> Date: Thu, 09 Aug 2012 10:25:14 +0300 From: Andris Pavenis User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120721 Thunderbird/14.0 MIME-Version: 1.0 To: bug-coreutils@gnu.org Subject: [date] wrong time returned from provided relative date description Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 09 Aug 2012 03:46:32 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) Noticed problems with command date: [apavenis@callisto Test]$ ./date-test.sh + date Thu Aug 9 10:16:31 EEST 2012 + date -d '2 weeks ago' Thu Jul 26 10:16:31 EEST 2012 + date -d 'thursday 2 weeks ago' Thu Jul 26 00:00:00 EEST 2012 + date -d 'next month' Sun Sep 9 10:16:31 EEST 2012 + date -d '1 monday next month' Thu Sep 13 00:00:00 EEST 2012 + date -d '2 monday next month' Thu Sep 20 00:00:00 EEST 2012 As one can see: 1) specifying both week day (eg. thursday) and week the actual date is taken from week next to specified week. It should perhaps be inside the specified week. The same happens if one uses 'this week', 'next week' etc. 2) specifying month and for example first monday generates date not from the begin of the month but uses the day in current month as reference Andris From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 09 04:19:09 2012 Received: (at 12162) by debbugs.gnu.org; 9 Aug 2012 08:19:09 +0000 Received: from localhost ([127.0.0.1]:43673 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzNxV-00017f-4X for submit@debbugs.gnu.org; Thu, 09 Aug 2012 04:19:09 -0400 Received: from mgw1.ipnetworks.fi ([88.148.165.20]:44578) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzNxR-00017U-Rx for 12162@debbugs.gnu.org; Thu, 09 Aug 2012 04:19:07 -0400 Received: (qmail 12245 invoked from network); 9 Aug 2012 08:10:49 -0000 Received: from unknown (HELO callisto.ipnetworks.fi) (apavenis@[192.168.152.176]) (envelope-sender ) by mgw1.ipnetworks.fi (qmail-ldap-1.03) with SMTP for <12162@debbugs.gnu.org>; 9 Aug 2012 08:10:49 -0000 Message-ID: <5023708E.7080909@iki.fi> Date: Thu, 09 Aug 2012 11:10:54 +0300 From: Andris Pavenis User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120721 Thunderbird/14.0 MIME-Version: 1.0 To: 12162@debbugs.gnu.org Subject: Tested coreutils versions Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12162 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Initially noticed on 8.4 (CentOS 6.3 x86_64). Also reproduced with 8.10 and 8.12 (Fedora 16). From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 09 16:52:04 2012 Received: (at 12162) by debbugs.gnu.org; 9 Aug 2012 20:52:04 +0000 Received: from localhost ([127.0.0.1]:45307 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzZi7-0003uG-UQ for submit@debbugs.gnu.org; Thu, 09 Aug 2012 16:52:04 -0400 Received: from joseki.proulx.com ([216.17.153.58]:35563) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SzZi4-0003tn-9i; Thu, 09 Aug 2012 16:52:02 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 3B7E8211D9; Thu, 9 Aug 2012 14:43:43 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id EB6DD2DCC1; Thu, 9 Aug 2012 14:43:42 -0600 (MDT) Date: Thu, 9 Aug 2012 14:43:42 -0600 From: Bob Proulx To: Andris Pavenis Subject: Re: bug#12162: [date] wrong time returned from provided relative date description Message-ID: <20120809204342.GA23321@hysteria.proulx.com> References: <502365DA.4080802@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <502365DA.4080802@iki.fi> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12162 Cc: 12162@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) tags 12162 + moreinfo thanks Andris Pavenis wrote: > Noticed problems with command date: Thanks for the report. However I do not understand what problem you are trying to report. Showing the output that you expected would help. > [apavenis@callisto Test]$ ./date-test.sh > + date > Thu Aug 9 10:16:31 EEST 2012 > + date -d '2 weeks ago' Here you are not specifying a time. This is problematic. Always specify a time along with a date for robust usage. Also knowing your exact timezone would be helpful. Also using the traditional output is ambiguous. Using -R produces a standard output that is unambiguous. $ TZ=US/Mountain date -R -d '12:00 2 weeks ago' Thu, 26 Jul 2012 12:00:00 -0600 See this reference for detailed information on this topic. http://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-working-right_002e > Thu Jul 26 10:16:31 EEST 2012 > + date -d 'thursday 2 weeks ago' > Thu Jul 26 00:00:00 EEST 2012 $ TZ=US/Mountain date -R -d 'thursday 12:00 2 weeks ago' Thu, 26 Jul 2012 12:00:00 -0600 > + date -d 'next month' > Sun Sep 9 10:16:31 EEST 2012 $ TZ=US/Mountain date -R -d '12:00 next month' Sun, 09 Sep 2012 12:00:00 -0600 > + date -d '1 monday next month' > Thu Sep 13 00:00:00 EEST 2012 $ TZ=US/Mountain date -R -d '12:00 1 monday next month' Thu, 13 Sep 2012 12:00:00 -0600 > + date -d '2 monday next month' > Thu Sep 20 00:00:00 EEST 2012 $ TZ=US/Mountain date -R -d '12:00 2 monday next month' Thu, 20 Sep 2012 12:00:00 -0600 All of the above yield expected results. > As one can see: > > 1) specifying both week day (eg. thursday) and week the actual > date is taken from week next to specified week. It should perhaps > be inside the specified week. The same happens if one uses > 'this week', 'next week' etc. The date documentation says: 28.6 Day of week items ====================== The explicit mention of a day of the week will forward the date (only if necessary) to reach that day of the week in the future. ... A number may precede a day of the week item to move forward supplementary weeks. It is best used in expression like `third monday'. In this context, `last DAY' or `next DAY' is also acceptable; they move one week before or after the day that DAY by itself would represent. Which explains specification in relation to the day of the week. > 2) specifying month and for example first monday generates > date not from the begin of the month but uses the day in current > month as reference Yes. This is also documented. Here in the date documentation it says: 28.7 Relative items in date strings =================================== "Relative items" adjust a date (or the current date if none) forward or backward. The effects of relative items accumulate. Here are some examples: 1 year 1 year ago 3 years 2 days The unit of time displacement may be selected by the string `year' or `month' for moving by whole years or months. These are fuzzy units, as years and months are not all of equal duration. More precise units are `fortnight' which is worth 14 days, `week' worth 7 days, `day' worth 24 hours, `hour' worth 60 minutes, `minute' or `min' worth 60 seconds, and `second' or `sec' worth one second. An `s' suffix on these units is accepted and ignored. The unit of time may be preceded by a multiplier, given as an optionally signed number. Unsigned numbers are taken as positively signed. No number at all implies 1 for a multiplier. Following a relative item by the string `ago' is equivalent to preceding the unit by a multiplier with value -1. The human date parsing code isn't very "tight" in that it is only a partial attempt at reading human input and converting that to a time value. There are many traps. In my opinion it is a feature that was put into production too early. But that is all water under the bridge now. It has been that way for a long time and now changing it would certainly break current usage. Bob From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 12 16:51:18 2012 Received: (at 12162) by debbugs.gnu.org; 12 Sep 2012 20:51:18 +0000 Received: from localhost ([127.0.0.1]:57841 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBtu2-0005GA-Aw for submit@debbugs.gnu.org; Wed, 12 Sep 2012 16:51:18 -0400 Received: from joseki.proulx.com ([216.17.153.58]:34719) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBtu1-0005G1-Bk; Wed, 12 Sep 2012 16:51:17 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 25EDC21250; Wed, 12 Sep 2012 14:50:29 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 757C92DC66; Wed, 12 Sep 2012 14:50:28 -0600 (MDT) Date: Wed, 12 Sep 2012 14:50:28 -0600 From: Bob Proulx To: Andris Pavenis Subject: Re: bug#12162: [date] wrong time returned from provided relative date description Message-ID: <20120912205027.GA25211@hysteria.proulx.com> References: <502365DA.4080802@iki.fi> <20120809204342.GA23321@hysteria.proulx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120809204342.GA23321@hysteria.proulx.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 12162 Cc: 12162@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.3 (--) tags 12162 - moreinfo close 12162 thanks I haven't seen a response to this in a month. Therefore I am closing the ticket as resolved. If you have new information or clarification please feel free to continue the discussion. Bob From unknown Fri Jun 20 07:10:21 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, 11 Oct 2012 11:24:04 +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