From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 25 12:01:58 2014 Received: (at submit) by debbugs.gnu.org; 25 Aug 2014 16:01:58 +0000 Received: from localhost ([127.0.0.1]:51894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XLwiQ-00016z-2w for submit@debbugs.gnu.org; Mon, 25 Aug 2014 12:01:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59274) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XLwiJ-00016U-TX for submit@debbugs.gnu.org; Mon, 25 Aug 2014 12:01:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XLwi6-0003RJ-K0 for submit@debbugs.gnu.org; Mon, 25 Aug 2014 12:01:42 -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.5 required=5.0 tests=BAYES_05,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:48828) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLwi6-0003RD-HD for submit@debbugs.gnu.org; Mon, 25 Aug 2014 12:01:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLwhz-0006te-Lh for bug-coreutils@gnu.org; Mon, 25 Aug 2014 12:01:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XLwhs-0003NY-MG for bug-coreutils@gnu.org; Mon, 25 Aug 2014 12:01:27 -0400 Received: from homie.mail.dreamhost.com ([208.97.132.208]:49202 helo=homiemail-a8.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLwhs-0003MW-Gt for bug-coreutils@gnu.org; Mon, 25 Aug 2014 12:01:20 -0400 Received: from homiemail-a8.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a8.g.dreamhost.com (Postfix) with ESMTP id AA8F1D22088 for ; Mon, 25 Aug 2014 09:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to :subject:date:message-id:mime-version:content-type: content-transfer-encoding; s=jidanni.org; bh=qdXurzIiAnbEZzT4d4M rJYVHdfs=; b=ZlKEDKqxfoGCiS86Kt8+q4VtDT9HRxJtQWKxk2XEd335yxwUWLd JGsA+omLammFncJKm7YTGqxssD6XtE57gAYHsFx90qv7ZFcb+adcOkvXEhbosRwc 8XUnyUEPDC+rIbJe7MzATlIRgihDfbBIy/E/6Ge9BKrvY5jAF/kcy+Pw= Received: from jidanni.org (111-246-102-246.dynamic.hinet.net [111.246.102.246]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a8.g.dreamhost.com (Postfix) with ESMTPSA id 5AFC4D22082 for ; Mon, 25 Aug 2014 09:01:18 -0700 (PDT) From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson To: bug-coreutils@gnu.org Subject: can't say date -d '8pm -0500' though other combos work Date: Tue, 26 Aug 2014 00:01:16 +0800 Message-ID: <87ppfo36er.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -5.0 (-----) $ date -d '8pm -0500' date: invalid date =E2=80=988pm -0500=E2=80=99 <--why can't this combo wo= rk? $ date -d '20:00 -0500' =E4=BA=8C 8=E6=9C=88 26 09:00:00 CST 2014 $ date -d 'sun 8pm' =E6=97=A5 8=E6=9C=88 31 20:00:00 CST 2014 $ date -d '8pm' =E4=B8=80 8=E6=9C=88 25 20:00:00 CST 2014 From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 20 00:25:12 2018 Received: (at 18328) by debbugs.gnu.org; 20 Oct 2018 04:25:12 +0000 Received: from localhost ([127.0.0.1]:60173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDip6-000354-K6 for submit@debbugs.gnu.org; Sat, 20 Oct 2018 00:25:12 -0400 Received: from mail-pl1-f181.google.com ([209.85.214.181]:41287) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDip4-00034k-ER; Sat, 20 Oct 2018 00:25:10 -0400 Received: by mail-pl1-f181.google.com with SMTP id p5-v6so1772218plq.8; Fri, 19 Oct 2018 21:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=RWs7K0jLeE2LOJnTqwfe3ComoQfxwOo+AeRg966eW9c=; b=OFy5sH78wMdt5lDH77biehinFLdFxt+gurZwR6Kc8HkKICMIcqnLTl7OnG8WY7kYWi CklRj00/NWO8cz8s7Il9e9TmRuavgP+QjRWqO//giST1KFS2n9qdw0cjrJlB+f6n7mmQ VgTfK8bHh83B9LaV8JJwkaf5KOuXtAGBX0ij4RYQih8/O3wzH33vWIqNnjadBEDsnTpJ 4bPJMznIfp5a1huS4HQFD3o2G2Wew5vMqP5z5/Ifun9qUOGgw6lUx/awyfzoWJNCAxhZ 8hjP56IVo97fGREbsHSCzh3GFVHykC4j0J2FxUYQ77+0FnGZQ4Cgsd78H8hzt9XMRqJ9 nQKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=RWs7K0jLeE2LOJnTqwfe3ComoQfxwOo+AeRg966eW9c=; b=hJm91wvHi++plC6epKcPejWNmG8zuHbMrdYeZzOFUwWptnc9AIX2CM4dbdW5DhtAId D//PA1PfEx8J7dqXKbs8ZPCvN8xdzzrVBEBBYUnB4T1xHT1RJP/SA/DmVsTs3ONvZ6DE fNT14Knuy8hZIjkkIDlEA+QK9s09qNk/YVzb2OCkzGzZ/FJBBe0pZx6gthvqUIAII5pA b9+6i4YHSJDZXl0C1+yUeG+NYVW39GmCa5voQf2IzE/xNAWXKBPkLFUpuEoEtcOEi7Ru tn3HhWoJacJtyZZAToGxT2hiP9kR6/ISBm8vx+BP6kxh4M91lG1IvtERDHHfnkjXB9WT +llA== X-Gm-Message-State: ABuFfohyJbYjqyu3gl8RdrVpW0Jl8f5eexjCD8oOzah6u0B5XkW/FyEN WgBJlOTuIdA3EQqCcRnp3EffAGrGbo0= X-Google-Smtp-Source: ACcGV60IqJ96xHOUzI4qgG82B27Hbm/JLGyPuJx3rIF4W4JCKOF+hY8+eEeU5RNA08CH85wBiuiHfA== X-Received: by 2002:a17:902:2b84:: with SMTP id l4-v6mr12471171plb.124.1540009503858; Fri, 19 Oct 2018 21:25:03 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id l129-v6sm33959759pfc.155.2018.10.19.21.25.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 21:25:02 -0700 (PDT) Subject: Re: bug#18328: can't say date -d '8pm -0500' though other combos work To: =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 18328@debbugs.gnu.org References: <87ppfo36er.fsf@jidanni.org> From: Assaf Gordon Message-ID: Date: Fri, 19 Oct 2018 22:25:00 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <87ppfo36er.fsf@jidanni.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 18328 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 (-) tags 18328 confirmed retitle 18328 date: '8pm -0500' is invalid (am/pm problem) stop (triaging old bugs) Hello, On 25/08/14 10:01 AM, 積丹尼 Dan Jacobson wrote: > $ date -d '8pm -0500' > date: invalid date ‘8pm -0500’ <--why can't this combo work? This is indeed a bug (specifically in gnulib's date parsing module, but easier to track here). It seems the existence of the "am/pm" string causes the parser to take a slightly different rule, then reject additional relative values, unless they have a unit, e.g.: $ date --debug -d '8pm +5 days' date: parsed time part: 08:00:00pm date: parsed relative part: +5 day(s) [...] Contrast it with a different (and confusing) rules when there is no "am/pm", the relative number is always taken as the time zone, e.g.: $ date --debug -d '8:00 +5 days' date: parsed time part: 08:00:00 UTC+05 date: parsed relative part: +1 day(s) date: input timezone: parsed date/time string (+05) [...] (from https://bugs.gnu.org/17161#31 ) I hope to get to this bug soon. -assaf From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 20 02:30:34 2018 Received: (at 18328) by debbugs.gnu.org; 20 Oct 2018 06:30:34 +0000 Received: from localhost ([127.0.0.1]:60188 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDkmQ-00087F-2M for submit@debbugs.gnu.org; Sat, 20 Oct 2018 02:30:34 -0400 Received: from pop.dreamhost.com ([64.90.62.162]:57632 helo=pdx1-sub0-mail-a43.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDkmM-000875-7p for 18328@debbugs.gnu.org; Sat, 20 Oct 2018 02:30:30 -0400 Received: from pdx1-sub0-mail-a43.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a43.g.dreamhost.com (Postfix) with ESMTP id 5CDAE80948; Fri, 19 Oct 2018 23:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=zJvQIblmhthlhGBqpJV3pM4Pii4=; b=mHKpn6UQIZcDU k5XdURvz6gPIHcXs3t/l7Szk5s51kPZ+yj25jEkrnnwxhCc/yNXVdArlU1c36Jl9 9cAMCNJ2ey+HQlFhfu3MObqJ0SHjPihJCIEa0FQGy9DlUCrUXUWc7g/VM2gUNYtc rB/mgO9AHvtWyTpDMR7B14yo6uixjo= Received: from jidanni.org (220-140-13-84.dynamic-ip.hinet.net [220.140.13.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by pdx1-sub0-mail-a43.g.dreamhost.com (Postfix) with ESMTPSA id AA17E80946; Fri, 19 Oct 2018 23:30:28 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a43 From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson To: Assaf Gordon Subject: Re: bug#18328: can't say date -d '8pm -0500' though other combos work References: <87ppfo36er.fsf@jidanni.org> Date: Sat, 20 Oct 2018 14:30:25 +0800 Message-ID: <87sh11dta6.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrfeejgdduudduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhffffkgggtsehttdertddttdejnecuhfhrohhmpejnnjjnucffrghnucflrggtohgsshhonhcuoehjihgurghnnhhisehjihgurghnnhhirdhorhhgqeenucfkphepvddvtddrudegtddrudefrdekgeenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepjhhiuggrnhhnihdrohhrghdpihhnvghtpedvvddtrddugedtrddufedrkeegpdhrvghtuhhrnhdqphgrthhhpeeprehuthhfqdekreeureehiehmpfehnfhiheehsgevkeerpecuffgrnhculfgrtghosghsohhnuceojhhiuggrnhhnihesjhhiuggrnhhnihdrohhrgheqpdhmrghilhhfrhhomhepjhhiuggrnhhnihesjhhiuggrnhhnihdrohhrghdpnhhrtghpthhtohepudekfedvkeesuggvsggsuhhgshdrghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 18328 Cc: 18328@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: -0.9 (/) AG> I hope to get to this bug soon. Good. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 29 01:15:09 2025 Received: (at 18328) by debbugs.gnu.org; 29 Jul 2025 05:15:09 +0000 Received: from localhost ([127.0.0.1]:59502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugcg7-0003jb-NC for submit@debbugs.gnu.org; Tue, 29 Jul 2025 01:15:09 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:40901) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ugcUD-0002q5-5I for 18328@debbugs.gnu.org; Tue, 29 Jul 2025 01:02:49 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-748e60725fcso627716b3a.3 for <18328@debbugs.gnu.org>; Mon, 28 Jul 2025 22:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753765363; x=1754370163; darn=debbugs.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=BSSK9TZkj5I0Qf/3FQIE4KjC8FsPxH3bdwuMYl0Dxuw=; b=IE+1e7RPlQb/j0MXSPuQG85hPaWETO4BFtQ7OesesxkLMIwMdSQXsWH24yq4POfwaj QX8HDZIVKOUTtA3xE0qVx0WWMDa6MXSPuDCVgA6NRDSGEUkplX3+ozQt/xtA5KNam9R2 R2tR4AFg8JzP2ac2I6LipJNcJfWmK+z+9FEje1QUx/7g5CTa42fShSOD3zn/eAj/vATW 3AIvNv5+81P0gOF2/I2YNThBv8N8rOcGJJ647rKelXnlj+1WvUbWc6iK0662GnTu6frn TcbrKI6XMGcBO1aeQgdtGvaXuO5C21aUmWS5c/Tl6yBNGYhzpm3c61MEsA+Nv9kmKLRL NQOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753765363; x=1754370163; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=BSSK9TZkj5I0Qf/3FQIE4KjC8FsPxH3bdwuMYl0Dxuw=; b=jeDM/w2tPobbyqnvRgXZSc++d/ETpKS8XX/qlmZTgpWLaw3xv0YxZtXhYExXLuF7I/ JeCT1NETxxAw2O5KXzrVSxlZNrDLGGPaUrFBb+NMlz4CZrF8wvKyEb5fZmYcDLPfiyTo IoGCxATjMHFBNH1ICZNrQaWc3J0WzU9ylPCb0F5zstAzo5XugGC7Rvl+ANxZjQskMzKg 63J0mZlfmq0gT0Sq1uqnrXYWhgFRYDZ7P45el2w7GDH6P5QOrnTokF3yD5rH4otT+f5o VCZ0+UegveoZ6LBlP6u7ew6vvD1zFijJ4prg1jILRH0+rz84AJH6OUrE3/ZfSgVqsO1H zJCA== X-Gm-Message-State: AOJu0YwFzmnBo0IsEaFeCwD185UO50rFiAo2ovJ4rwKrx2x/Bn0cZozW BWd8czRORAh16/4tFF/aeY2+loti1Va/19HdBcr4siavC+qe8g8m9ODaiFHsnaw+y3mPCQEHPSr ExqA8yvFLTWbhxclypItYzt9mTd9si5P4fmlQuDo= X-Gm-Gg: ASbGncsQNLQDEwIyMiXZGFn6ZdQ1HT0mSEAlcuMqK6K/XzW+tEtSCCHHeaFtUKniEwH KthrqwBFG2dMkRTxOQBYA5LO15zLicB4HjkMg0MlLAbpGh+ltq4AEdANsKLbeavWaw0FN2qBRCe PCtcfvegfb+y73pbfdiJEQLe7r328KVU8AI1KVu2H50G6VmC+1s8z3KupJcGyltO3IxUreo2PHX fqS6UA= X-Google-Smtp-Source: AGHT+IETxprXuUOZ8KukxEejt86JhP9CipFj7jLg1iF4gNMQIUTMZ8ACIH9ExaJZjg3h2XU1HYYlIM0x36wagm/yIhA= X-Received: by 2002:a05:6a21:6494:b0:231:242:2596 with SMTP id adf61e73a8af0-23d7018390cmr9440322637.5.1753765362621; Mon, 28 Jul 2025 22:02:42 -0700 (PDT) MIME-Version: 1.0 From: Jeffery Palm Date: Mon, 28 Jul 2025 22:02:30 -0700 X-Gm-Features: Ac12FXwofEAAMGBNv9lBXbVm-NDLkNs1kFyfxm1krdChaHCkzibHitJmbB4RWJI Message-ID: Subject: Re: bug#18328: can't say date -d '8pm -0500' though other combos work To: 18328@debbugs.gnu.org Content-Type: multipart/alternative; boundary="0000000000007560d4063b0a51ea" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 18328 X-Mailman-Approved-At: Tue, 29 Jul 2025 01:15:05 -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: -1.0 (-) --0000000000007560d4063b0a51ea Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I took a look at this bug, and believe I have a patch that will resolve it. $ ../src/date --debug -d '2024-01-01 8:00:00PM -0500' date: parsed date part: (Y-M-D) 2024-01-01 date: parsed time part: 08:00:00pm UTC-05 date: input timezone: parsed date/time string (-05) date: using specified time as starting value: '20:00:00' date: starting date/time: '(Y-M-D) 2024-01-01 20:00:00 TZ=3D-05' date: '(Y-M-D) 2024-01-01 20:00:00 TZ=3D-05' =3D 1704157200 epoch-seconds date: timezone: system default date: final: 1704157200.000000000 (epoch-seconds) date: final: (Y-M-D) 2024-01-02 01:00:00 (UTC) date: final: (Y-M-D) 2024-01-01 17:00:00 (UTC-08) date: output format: =E2=80=98%a %d %b %Y %T %Z=E2=80=99 Mon 01 Jan 2024 17:00:00 PST And I was able to run the coreutils testsuite with no tests failing: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D Testsuite summary for GNU coreutils 9.7.174-083f8 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D # TOTAL: 533 # PASS: 476 # SKIP: 57 # XFAIL: 0 # FAIL: 0 # XPASS: 0 # ERROR: 0 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D Are there any other tests/changes I should consider for this? Below is the patch for the changes I made for this, including a new testcase for AM/PM with timezone. --- a/lib/parse-datetime.y +++ b/lib/parse-datetime.y @@ -592,7 +592,7 @@ debug_print_relative_time (char const *item, parser_control const *pc) %token tYEAR_UNIT tMONTH_UNIT tHOUR_UNIT tMINUTE_UNIT tSEC_UNIT %token tDAY_UNIT tDAY_SHIFT -%token tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN +%token tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN tMERIDIAN_WITH_ZONE %token tMONTH tORDINAL tZONE %token tSNUMBER tUNUMBER @@ -698,6 +698,27 @@ time: set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); pc->meridian =3D $6; } + | tUNUMBER tMERIDIAN_WITH_ZONE tSNUMBER o_colon_minutes + { + set_hhmmss (pc, $1.value, 0, 0, 0); + pc->meridian =3D $2; + pc->zones_seen++; + if (! time_zone_hhmm (pc, $3, $4)) YYABORT; + } + | tUNUMBER ':' tUNUMBER tMERIDIAN_WITH_ZONE tSNUMBER o_colon_minutes + { + set_hhmmss (pc, $1.value, $3.value, 0, 0); + pc->meridian =3D $4; + pc->zones_seen++; + if (! time_zone_hhmm (pc, $5, $6)) YYABORT; + } + | tUNUMBER ':' tUNUMBER ':' unsigned_seconds tMERIDIAN_WITH_ZONE tSNUMBER o_colon_minutes + { + set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); + pc->meridian =3D $6; + pc->zones_seen++; + if (! time_zone_hhmm (pc, $7, $8)) YYABORT; + } | iso_8601_time ; @@ -1527,14 +1548,19 @@ yylex (union YYSTYPE *lvalp, parser_control *pc) *p =3D '\0'; tp =3D lookup_word (pc, buff); - if (! tp) + if (tp) { - if (debugging (pc)) - dbg_printf (_("error: unknown word '%s'\n"), buff); - return '?'; + lvalp->intval =3D tp->value; + if (tp->type =3D=3D tMERIDIAN) + { + char const *p =3D pc->input; + while (*p && c_isspace (*p)) + p++; + if (*p =3D=3D '-' || *p =3D=3D '+') + return tMERIDIAN_WITH_ZONE; + } + return tp->type; } - lvalp->intval =3D tp->value; - return tp->type; } if (c !=3D '(') diff --git a/tests/test-parse-datetime.c b/tests/test-parse-datetime.c index 546b383c55..9766ed7a13 100644 --- a/tests/test-parse-datetime.c +++ b/tests/test-parse-datetime.c @@ -335,6 +335,15 @@ main (_GL_UNUSED int argc, char **argv) ASSERT (result.tv_sec =3D=3D result2.tv_sec && result.tv_nsec =3D=3D result2.tv_nsec); + /* Check that timeone works with AM/PM */ + p =3D "2024-01-01 8PM -08:00"; + expected.tv_sec =3D 1704168000; + expected.tv_nsec =3D 0; + ASSERT (parse_datetime (&result, p, NULL)); + LOG (p, expected, result); + ASSERT (expected.tv_sec =3D=3D result.tv_sec + && expected.tv_nsec =3D=3D result.tv_nsec); + /* TZ out of range should cause parse_datetime failure */ now.tv_sec =3D SOME_TIMEPOINT + 4711; --0000000000007560d4063b0a51ea Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I took a look at this bug, and believe=C2=A0I have a = patch that will resolve it.

$ ../src/date --debug = -d '2024-01-01 8:00:00PM -0500'
date: parsed date part: (Y-M-D) = 2024-01-01
date: parsed time part: 08:00:00pm UTC-05
date: input time= zone: parsed date/time string (-05)
date: using specified time as starti= ng value: '20:00:00'
date: starting date/time: '(Y-M-D) 2024= -01-01 20:00:00 TZ=3D-05'
date: '(Y-M-D) 2024-01-01 20:00:00 TZ= =3D-05' =3D 1704157200 epoch-seconds
date: timezone: system default<= br>date: final: 1704157200.000000000 (epoch-seconds)
date: final: (Y-M-D= ) 2024-01-02 01:00:00 (UTC)
date: final: (Y-M-D) 2024-01-01 17:00:00 (UT= C-08)
date: output format: =E2=80=98%a %d %b %Y %T %Z=E2=80=99
Mon 01= Jan 2024 17:00:00 PST


And I was ab= le to run the coreutils testsuite with no tests failing:

=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Te= stsuite summary for GNU coreutils 9.7.174-083f8
=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
# TOTAL: 533
#= PASS: =C2=A0476
# SKIP: =C2=A057
# XFAIL: 0
# FAIL: =C2=A00
# = XPASS: 0
# ERROR: 0
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Are there any other= tests/changes I should consider for this?


Below is the patch for the changes I made for this, including a new= testcase=C2=A0for AM/PM with timezone.=C2=A0


=
--- a/lib/parse-datetime.y
+++ b/lib/parse-datetime.y
@@ -= 592,7 +592,7 @@ debug_print_relative_time (char const *item, parser_control= const *pc)
=C2=A0%token tYEAR_UNIT tMONTH_UNIT tHOUR_UNIT tMINUTE_UNIT = tSEC_UNIT
=C2=A0%token <intval> tDAY_UNIT tDAY_SHIFT
=C2=A0
= -%token <intval> tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN
+%token <i= ntval> tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN tMERIDIAN_WITH_ZONE
=C2=A0= %token <intval> tMONTH tORDINAL tZONE
=C2=A0
=C2=A0%token <t= extintval> tSNUMBER tUNUMBER
@@ -698,6 +698,27 @@ time:
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.t= v_nsec);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pc->meridian =3D $6;
= =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0| tUNUMBER tMERIDIAN_WITH_ZONE tSNU= MBER o_colon_minutes
+ =C2=A0 =C2=A0 =C2=A0{
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0set_hhmmss (pc, $1.value, 0, 0, 0);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0p= c->meridian =3D $2;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0pc->zones_seen++;=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (! time_zone_hhmm (pc, $3, $4)) YYABORT= ;
+ =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0| tUNUMBER ':' tUNUMBER tME= RIDIAN_WITH_ZONE tSNUMBER o_colon_minutes
+ =C2=A0 =C2=A0 =C2=A0{
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0set_hhmmss (pc, $1.value, $3.value, 0, 0);
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0pc->meridian =3D $4;
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0pc->zones_seen++;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (! time_z= one_hhmm (pc, $5, $6)) YYABORT;
+ =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0| tUN= UMBER ':' tUNUMBER ':' unsigned_seconds tMERIDIAN_WITH_ZONE= tSNUMBER o_colon_minutes
+ =C2=A0 =C2=A0 =C2=A0{
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec);
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0pc->meridian =3D $6;
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0pc->zones_seen++;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (! time_z= one_hhmm (pc, $7, $8)) YYABORT;
+ =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0= | iso_8601_time
=C2=A0 =C2=A0;
=C2=A0
@@ -1527,14 +1548,19 @@ yyle= x (union YYSTYPE *lvalp, parser_control *pc)
=C2=A0
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0*p =3D '\0';
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0tp =3D lookup_word (pc, buff);
- =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0if (! tp)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (tp)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{
- =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0if (debugging (pc))
- =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dbg_printf (_("error: unknown word &= #39;%s'\n"), buff);
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0return '?';
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0lvalp->intval =3D tp->value;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0if (tp->type =3D=3D tMERIDIAN)
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0char const *p =3D pc->input;
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0while (*p &&= amp; c_isspace (*p))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0p++;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0if (*p =3D=3D '-' || *p =3D=3D '+')
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return= tMERIDIAN_WITH_ZONE;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0}
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return tp->= ;type;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
- =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0lvalp->intval =3D tp->value;
- =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0return tp->type;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0}
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0if (c !=3D '(')
= diff --git a/tests/test-parse-datetime.c b/tests/test-parse-datetime.c
i= ndex 546b383c55..9766ed7a13 100644
--- a/tests/test-parse-datetime.c
= +++ b/tests/test-parse-datetime.c
@@ -335,6 +335,15 @@ main (_GL_UNUSED = int argc, char **argv)
=C2=A0 =C2=A0ASSERT (result.tv_sec =3D=3D result2= .tv_sec
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& result.tv_ns= ec =3D=3D result2.tv_nsec);
=C2=A0
+ =C2=A0/* Check that timeone work= s with AM/PM */
+ =C2=A0p =3D "2024-01-01 8PM -08:00";
+ = =C2=A0expected.tv_sec =3D 1704168000;
+ =C2=A0expected.tv_nsec =3D 0;+ =C2=A0ASSERT (parse_datetime (&result, p, NULL));
+ =C2=A0LOG (p,= expected, result);
+ =C2=A0ASSERT (expected.tv_sec =3D=3D result.tv_sec=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& expected.tv_nsec =3D=3D = result.tv_nsec);
+
=C2=A0
=C2=A0 =C2=A0/* TZ out of range should c= ause parse_datetime failure */
=C2=A0 =C2=A0now.tv_sec =3D SOME_TIMEPOIN= T + 4711;
--0000000000007560d4063b0a51ea-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 29 07:22:44 2025 Received: (at 18328) by debbugs.gnu.org; 29 Jul 2025 11:22:44 +0000 Received: from localhost ([127.0.0.1]:60895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugiPr-0005if-LH for submit@debbugs.gnu.org; Tue, 29 Jul 2025 07:22:44 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:51440) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ugiPo-0005iA-OZ for 18328@debbugs.gnu.org; Tue, 29 Jul 2025 07:22:42 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4538bc52a8dso40388635e9.2 for <18328@debbugs.gnu.org>; Tue, 29 Jul 2025 04:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753788154; x=1754392954; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:cc:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=My4k/0ua/s0rvkS3F6UuacesDLlE7JtsDY5q93LGMXo=; b=mWrNSXtWaog5Ztpd83nPMo4+SkOHXNBCaI//AtvcK6pTyq3UmLHv4Ac8cWov9QhzcP fFK5iSEhHrfQofKYf04MzV6WtvDB/N8+mT9e0WZuA1crOUTKtp4o5Tz6vZTE06e0PIbU YuHhoTn70OgeFWxrxmJ45YvmJjzcaJUwGQrHt/9DNdrbLaJrpZCaj6L8r7Vc6iidT8+4 WxrXu1ZHKlOOvfYKe+mse+0SHywDK4JGDIF7Rrv9lCE/1wCQO/E4tlbH/lM6OEfc74gH GixNa1rEl3b4LEgIC3BrSExDs7Bzp0NJAuIQvLcZ7Qf0UxgnZQhVJx//DDQnIxLYO/dL QcKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753788154; x=1754392954; h=content-transfer-encoding:in-reply-to:cc:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=My4k/0ua/s0rvkS3F6UuacesDLlE7JtsDY5q93LGMXo=; b=k0L66W8Bj80yaDfgL8EJ+D5C8yY3mKj/FmnQLXfkYTxJ8fqWzUUref2gW48pPtswSY QmfCTeCR51cnBpc0DPRRdePW7wgIMzaX15Y63Le7MmSuO23H01xvDgulrtG1JVg/wv7R QaeuYLseZzJwClzk7G553653QfY1MgbofXRHgxzzIU5K6Q2NDtyP5oH/YWeWa4esH6jv UFjw0wKxIFQUfuR0Plwyle2A2yZG6wMbXAktZO4A/UgeRzlavgiUsVk3NoAYybAogMPy sClUMuff40qkGmyf1/y6ZXRYsOU6UR+700k1ymwUBIF/GBjuEPfTbMbEm149u92Q1IB3 y21w== X-Forwarded-Encrypted: i=1; AJvYcCUQLlAXnonSx2Unm0UVO2PMe0fROhrZKpfVNy10GTmj8+A90Hu9ZoK0He0OZ3t9tkPZaEDj9g==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzkXtzf4AfcEwcOxqZRxrE3gzK/LtB/YYJjwJyNPv+v2ou3qS17 RDIWKrvXtjoxL9boaX1WPDxWy4pr9AttzPZeWJpq8Dyw8puTXY/sUMmk X-Gm-Gg: ASbGncucS1nIbAH79MIDMtfxzsvFVVOtX/u7hoVHvDE2206geekVuC2P/O2cwycq/st QcJX4aunO+fgcn8mUX8f8sMT+nM1bAIcUEs4Duz9sIov1VCMToYnJLqtURuhSVgwMaecwus0Ren ZPY7g6sfQHfY+Y1ZzA+7u8XEK6Ds7FokvCK3OBN1BwV0GElvXSyNmTla2nP2ZIKoq2Uigfc57pY mt3fYv9ruPhd3Tts6e3ZTstTmRZEkmIReBqHplC1gsq5jGWzQ2sGhIGJnICBLkwRXUhXjGD/2WM X+oIG9hF3ZsKobW+WaKhcv3wyQHlr2E+b0YWrPgCaBc1JYZRwvVWIYVy6egs9ZwuCBzWR+c770k QLwPtBL+eJywKP7nuPbPXW/H9tiBtz0E/C8G4NE6Rm6Nzb+5XS0CSY0x74NFXbxtc9Y9/PXzcym jeiBmGYWkbtxF6 X-Google-Smtp-Source: AGHT+IHB7ZT/rgpJvo5E+hVMnSrYaPMMJFeDEVNKli1RzXu/b60oTWQb8DYjHwC5XtjF2ND4Xtv1Pg== X-Received: by 2002:a05:600c:518d:b0:456:2bac:8f8 with SMTP id 5b1f17b1804b1-45876449eb8mr126156935e9.16.1753788153849; Tue, 29 Jul 2025 04:22:33 -0700 (PDT) Received: from [192.168.1.31] (86-44-211-146-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.44.211.146]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4588e5c58e9sm20400625e9.14.2025.07.29.04.22.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Jul 2025 04:22:33 -0700 (PDT) Message-ID: <3c15c4fd-de25-4333-aeb6-af70dd02e29a@draigBrady.com> Date: Tue, 29 Jul 2025 12:22:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: bug#18328: can't say date -d '8pm -0500' though other combos work To: Jeffery Palm , 18328@debbugs.gnu.org References: <87ppfo36er.fsf@jidanni.org> Content-Language: en-US From: =?UTF-8?Q?P=C3=A1draig_Brady?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 18328 Cc: Geoff Kuenning 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 (-) On 29/07/2025 06:02, Jeffery Palm wrote: > I took a look at this bug, and believe I have a patch that will resolve it. > > $ ../src/date --debug -d '2024-01-01 8:00:00PM -0500' > date: parsed date part: (Y-M-D) 2024-01-01 > date: parsed time part: 08:00:00pm UTC-05 > date: input timezone: parsed date/time string (-05) > date: using specified time as starting value: '20:00:00' > date: starting date/time: '(Y-M-D) 2024-01-01 20:00:00 TZ=-05' > date: '(Y-M-D) 2024-01-01 20:00:00 TZ=-05' = 1704157200 epoch-seconds > date: timezone: system default > date: final: 1704157200.000000000 (epoch-seconds) > date: final: (Y-M-D) 2024-01-02 01:00:00 (UTC) > date: final: (Y-M-D) 2024-01-01 17:00:00 (UTC-08) > date: output format: ‘%a %d %b %Y %T %Z’ > Mon 01 Jan 2024 17:00:00 PST > > > And I was able to run the coreutils testsuite with no tests failing: > > ============================================================================ > Testsuite summary for GNU coreutils 9.7.174-083f8 > ============================================================================ > # TOTAL: 533 > # PASS: 476 > # SKIP: 57 > # XFAIL: 0 > # FAIL: 0 > # XPASS: 0 > # ERROR: 0 > ============================================================================ > > Are there any other tests/changes I should consider for this? > > > Below is the patch for the changes I made for this, including a new > testcase for AM/PM with timezone. > > > --- a/lib/parse-datetime.y > +++ b/lib/parse-datetime.y > @@ -592,7 +592,7 @@ debug_print_relative_time (char const *item, > parser_control const *pc) > %token tYEAR_UNIT tMONTH_UNIT tHOUR_UNIT tMINUTE_UNIT tSEC_UNIT > %token tDAY_UNIT tDAY_SHIFT > > -%token tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN > +%token tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN tMERIDIAN_WITH_ZONE > %token tMONTH tORDINAL tZONE > > %token tSNUMBER tUNUMBER > @@ -698,6 +698,27 @@ time: > set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); > pc->meridian = $6; > } > + | tUNUMBER tMERIDIAN_WITH_ZONE tSNUMBER o_colon_minutes > + { > + set_hhmmss (pc, $1.value, 0, 0, 0); > + pc->meridian = $2; > + pc->zones_seen++; > + if (! time_zone_hhmm (pc, $3, $4)) YYABORT; > + } > + | tUNUMBER ':' tUNUMBER tMERIDIAN_WITH_ZONE tSNUMBER o_colon_minutes > + { > + set_hhmmss (pc, $1.value, $3.value, 0, 0); > + pc->meridian = $4; > + pc->zones_seen++; > + if (! time_zone_hhmm (pc, $5, $6)) YYABORT; > + } > + | tUNUMBER ':' tUNUMBER ':' unsigned_seconds tMERIDIAN_WITH_ZONE > tSNUMBER o_colon_minutes > + { > + set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); > + pc->meridian = $6; > + pc->zones_seen++; > + if (! time_zone_hhmm (pc, $7, $8)) YYABORT; > + } > | iso_8601_time > ; > > @@ -1527,14 +1548,19 @@ yylex (union YYSTYPE *lvalp, parser_control *pc) > > *p = '\0'; > tp = lookup_word (pc, buff); > - if (! tp) > + if (tp) > { > - if (debugging (pc)) > - dbg_printf (_("error: unknown word '%s'\n"), buff); > - return '?'; > + lvalp->intval = tp->value; > + if (tp->type == tMERIDIAN) > + { > + char const *p = pc->input; Better to use a non shadowing name here ^ > + while (*p && c_isspace (*p)) > + p++; > + if (*p == '-' || *p == '+') > + return tMERIDIAN_WITH_ZONE; > + } > + return tp->type; > } > - lvalp->intval = tp->value; > - return tp->type; > } > > if (c != '(') > diff --git a/tests/test-parse-datetime.c b/tests/test-parse-datetime.c > index 546b383c55..9766ed7a13 100644 > --- a/tests/test-parse-datetime.c > +++ b/tests/test-parse-datetime.c > @@ -335,6 +335,15 @@ main (_GL_UNUSED int argc, char **argv) > ASSERT (result.tv_sec == result2.tv_sec > && result.tv_nsec == result2.tv_nsec); > > + /* Check that timeone works with AM/PM */ > + p = "2024-01-01 8PM -08:00"; > + expected.tv_sec = 1704168000; > + expected.tv_nsec = 0; > + ASSERT (parse_datetime (&result, p, NULL)); > + LOG (p, expected, result); > + ASSERT (expected.tv_sec == result.tv_sec > + && expected.tv_nsec == result.tv_nsec); > + > > /* TZ out of range should cause parse_datetime failure */ > now.tv_sec = SOME_TIMEPOINT + 4711; Thanks for looking at this. This changes relative handling unfortunately: $ src/date --debug -d '2024-01-01 8:00:00PM -5 days' date: parsed date part: (Y-M-D) 2024-01-01 date: parsed time part: 08:00:00pm UTC-05 date: parsed relative part: +1 day(s) ... Wed 03 Jan 2024 01:00:00 GMT $ date --debug -d '2024-01-01 8:00:00PM -5 days' date: parsed date part: (Y-M-D) 2024-01-01 date: parsed time part: 08:00:00pm date: parsed relative part: -5 day(s) ... Wed 27 Dec 2023 20:00:00 GMT Now there is an existing ambiguity here, where the AM/PM induces the relative interpretation: $ date --debug -d '2024-01-01 8:00:00PM -5 days' date: parsed date part: (Y-M-D) 2024-01-01 date: parsed time part: 08:00:00pm date: parsed relative part: -5 day(s) $ date --debug -d '2024-01-01 8:00:00 -5 days' date: parsed date part: (Y-M-D) 2024-01-01 date: parsed time part: 08:00:00 UTC-05 date: parsed relative part: +1 day(s) BTW https://bugs.gnu.org/79078 was a recent bug report along the same lines of the relative part being unexpectedly considered as a timezone offset Now I agree we're already inconsistent in this regard, but I'm sure folks are relying on the AM/PM inducing a relative interpretation. If we were trying to make all this more consistent, IMHO we should change things so that we always interpret +|- as a relative adjustment, whereas your change does the opposite for the AM/PM case. cheers, Padraig