From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#52209: 28.0.60; [PATCH] date-to-time fails on pure dates Date: Wed, 05 Jan 2022 16:46:01 +0100 Message-ID: <87lezudw3q.fsf@gnus.org> References: <7c22f300-eedb-da65-db02-e82025ec2f48@cs.ucla.edu> <25023.40959.627321.685762@orion.rgrjr.com> <875yrjpp03.fsf@gnus.org> <25024.42989.718735.680188@orion.rgrjr.com> <871r26i5n0.fsf@gnus.org> <25028.53876.304365.706795@orion.rgrjr.com> <87zgoq2vwm.fsf@gnus.org> <25029.60989.564217.290743@orion.rgrjr.com> <87bl1428x5.fsf@gnus.org> <25031.40994.286546.498819@orion.rgrjr.com> <87ee5zzjpg.fsf@gnus.org> <25035.12991.328986.987982@orion.rgrjr.com> <87o84z782g.fsf@gnus.org> <25038.8156.470964.935330@orion.rgrjr.com> <87lezz5x92.fsf@gnus.org> <87h7an7bdm.fsf@igel.home> <25040.62646.635818.692654@orion.rgrjr.com> <87mtkd3vee.fsf@gnus.org> <25043.53490.928476.622599@orion.rgrjr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27347"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 52209@debbugs.gnu.org, Andreas Schwab , Paul Eggert To: Bob Rogers Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 05 16:47:12 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n58VL-0006vL-Sr for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Jan 2022 16:47:11 +0100 Original-Received: from localhost ([::1]:38376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n58VJ-0004nx-S8 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Jan 2022 10:47:09 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n58VC-0004nS-Pd for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 10:47:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58165) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n58VC-0006K7-Fb for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 10:47:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n58VC-0007Yy-E4 for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 10:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Jan 2022 15:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52209 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 52209-submit@debbugs.gnu.org id=B52209.164139757929013 (code B ref 52209); Wed, 05 Jan 2022 15:47:02 +0000 Original-Received: (at 52209) by debbugs.gnu.org; 5 Jan 2022 15:46:19 +0000 Original-Received: from localhost ([127.0.0.1]:41478 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n58UV-0007Xt-8y for submit@debbugs.gnu.org; Wed, 05 Jan 2022 10:46:19 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:56270) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n58UT-0007Xf-9Q for 52209@debbugs.gnu.org; Wed, 05 Jan 2022 10:46:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6rbvgV7ZroBSGyskNNucqc1421nvS8hW7K2kCKCrMbs=; b=MoA9fkuxsu4AmdDfk3LsnePTnS chHQFUrtXjpNiPufqpr0bPmKaGKCJ9qVr101Bp5ySQATCRh1K6whYMY4MhJwcObqeapIgEYW05B+3 U0F0UlKZLvJXit95cp2aGBR22eYKHKrXEBuBAEeh0nZh7MugnrSoC89di3AT16zKckHA=; Original-Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n58UH-0005jh-UF; Wed, 05 Jan 2022 16:46:09 +0100 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEXw8PBdXV2joqP/ //8t2MV5AAAAAWJLR0QDEQxM8gAAAAd0SU1FB+YBBQ8hEesE+ZEAAAFTSURBVCjPjZGxasMwEIYv ojF2phI6ZDShMa6ewkuGbg00xngKpRLGT6GaJiSeMpQQMgnTmuSesifZqV269IaTvtPp190J4Jfd 5O8rt3S3O0UwFPXqXgopDXjzu2iYybk0aY6onz1nvhaRBZl46/XnI6XxAgvEM0fEI3C8XJYIVbiF WwN5BqyanMGHAE+ablYcCXjqG03EShMoW0elNIRg440PSaIxZiIt0H0yA0yjslfHBl7yRmZ87PXG L7qDKaoOxr2D5jkG5dmmGTdA1CNKn5gDlqLyQ/vo7E1qBE0wbcTIF9oKuH5PrVRUs3uV1u3GN520 LdIy0x2w/EP9wMB1ulJdzq5DoIRRG+z56/If481H0YfhHh7S+KteYp6e8j3AIanUNiwcr6a34nix yAIhNgeaRRSn1dPsVZTUNkvSJIsCKXZmWLFYJKtgtxFB19efcr4ByGtiboM3kVUAAAAldEVYdGRh dGU6Y3JlYXRlADIwMjItMDEtMDVUMTU6MzM6MTcrMDA6MDB0j0NLAAAAJXRFWHRkYXRlOm1vZGlm eQAyMDIyLTAxLTA1VDE1OjMzOjE3KzAwOjAwBdL79wAAAABJRU5ErkJggg== X-Now-Playing: Neil Young & Crazy Horse's _Zuma_: "Drive Back" In-Reply-To: <25043.53490.928476.622599@orion.rgrjr.com> (Bob Rogers's message of "Mon, 3 Jan 2022 23:45:38 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:223692 Archived-At: Bob Rogers writes: > One thing regexps can't do (at least not without adding a fair bit of > complexity) is allow components to be in different order or omitted. So > it still just takes one approximate date/time, and the caller is back to > writing regexps to validate before passing it to the "real" parser. Yes. But you can't just have a function that you can give any string to and it'll tell you what the date contained in it is. "1.2" is a perfectly normal way to specify "January second" in some countries, but no amount of general DWIM is going to take us there. The caller has to say what they expect the format to be is. > I was thinking that the next dimension in which to extend parse-date > would be to add keywords to refine what is accepted, on top of the basic > MDY order, e.g.: > > :date-separators "-/" > :time-separators ":." > :two-numbers-are :month-year ;; or (e.g.) :day-month > :timezone :required ;; could be :optional or :forbidden > :timezone-has-colon t ;; RFC5322 forbids, ISO-8601 requires > > Some keywords could even be regexp-valued. Others could be "umbrella" > keywords that change the defaults for subsets of more specific keywords. > In any case, that should make patching to add new features easier and > (eventually) allow for much more fine tuning by callers. I think it'd be easier to just write a regexp than to use a date-parsing function like that. =F0=9F=98=80 > (And I think if we had that, then implementing DWIM-ish parsing of, > say, US dates on top of that would be a matter of writing a series of > these strings to match them. Probably.) > > If I understand you correctly, this parse-date-DWIMishly would go > through the string and recognize (say) that it had come to something > that matches "%M/%d/%Y", concatenate that to a strptime-like format > string it was building, and then call parse-date-strptime-style (or > whatever) with that and the original string. But it seems to me that if > it could recognize that it had found "%M/%d/%Y" in the string, it would > be much easier to just fill in the month, day, and year right then. Well, I was thinking more like looping over a common set of formats and see whether we have a match. For the US, looping over "%M.*%d.*%Y?", "%M.*%b.*%Y?" and "%M.*%B.*%Y?" would probably cover most of the American-language dates. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no