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.devel Subject: Re: Shorter and more flexible implementation for parse-time.el Date: Sat, 24 Jul 2021 14:12:25 +0200 Message-ID: <87mtqb3o7q.fsf@gnus.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5596"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: "Guu, Jin-Cheng" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jul 24 14:13:08 2021 Return-path: Envelope-to: ged-emacs-devel@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 1m7GWi-0001Cv-LH for ged-emacs-devel@m.gmane-mx.org; Sat, 24 Jul 2021 14:13:08 +0200 Original-Received: from localhost ([::1]:45448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m7GWe-0001Ad-EM for ged-emacs-devel@m.gmane-mx.org; Sat, 24 Jul 2021 08:13:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7GW7-0000Tf-RU for emacs-devel@gnu.org; Sat, 24 Jul 2021 08:12:31 -0400 Original-Received: from quimby.gnus.org ([2a01:4f9:2b:f0f::2]:51182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7GW6-0002oH-Fx for emacs-devel@gnu.org; Sat, 24 Jul 2021 08:12:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: 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=M2iFB65zR2K+axdAC0VmjZygu6TJp+FVu5yPcQblDsI=; b=fhk4dByT+lLNjkEavxYwDKdvHC 3J8IEbMynXEAMt/ZfDsXlzXbEWNoTf/snPmyvDblmkyc8H/oiiIwfRfFUNqX3dtiKpx43dtQp6EmU erf9js8M8UL5oFc/IFxJtvJCRXrZHDm4kVhC9i4gr4ZXZ73AocgKdYKoNN1VQZPhVC7E=; Original-Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m7GW1-000510-M9; Sat, 24 Jul 2021 14:12:28 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAElBMVEUQFBg5TF1VcZBv hp3Bwr////9uWi7SAAAAAWJLR0QF+G/pxwAAAAd0SU1FB+UHGAwIKFmmWGcAAAGySURBVDjLdZMB muIwCIVh9gJA9wCFeIBJ4gXcnfufaR9J1GrdWLVf/vIID0pESh8XqwquM9CxhM8RkhH4+0/EWUzd wgLsQ3JTE/qQX8hpPwM8y2r+ITvSI4eQTGF7O5ev+5g3eFABnKuNEs3DEY8FzuxKhgMIcXhIxidg 6NL3l6R2An2CPBZPH49AOYEOkOoj94yQuxucWVWZeSRHjlVbrFXGqeC4z+osDstXNbKE/BVwgohz RIIXoZhpE3B72Z59w49sh+0sbQBHxFAqvcWO6XgAkgFKd9TEonepWAAuk4o++5Ngm4MyXMuOZBcg RYLqk+TMRMNntMfXOE7DW+mQraOfAEMjSuvROlaro20ISol+WHW0jXi3UvobQITwftymCTBKxvtz uy2ArG6uT/C97QPoG7jeSjrq94iZA4VdbigzTTRtCXBJvlby+1aGMQBR8epIvgfohF7+2gH4fDty 7H5+ZAKkSKnpU1i7Avzq8CojDPlLSZeiX/4QQHuAVXnguERb1mHmFd8NXk9QhbbSskCrcGVLL3ov /SoAfQCtqjt7DgMiGtED4LA5u/yYgi9Y8g/BjluI0nu+VwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAy MS0wNy0yNFQxMjowODo0MCswMDowMDtJTwoAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDctMjRU MTI6MDg6NDArMDA6MDBKFPe2AAAAAElFTkSuQmCC X-Now-Playing: Depeche Mode's _Some Great Reward_: "Something To Do" In-Reply-To: (Jin-Cheng Guu's message of "Fri, 23 Jul 2021 12:03:33 -0500") Received-SPF: pass client-ip=2a01:4f9:2b:f0f::2; envelope-from=larsi@gnus.org; helo=quimby.gnus.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271539 Archived-At: "Guu, Jin-Cheng" writes: > Currently, the built-in time parsing functions only allow us to parse > timestrings with respect to some given formats (ISO-8601, RFC-822) > [1]. I have a parsing function that allows users to parse with > customized formats which are easy to write. The end result is: > > ``` emacs-lisp > (my/parse-time "20200718-201504" > '((:year 4) (:month 2) (:day 2) "-" > (:hour 2) (:minute 2) (:second 2))) > ;; => ((:second . 4) (:minute . 15) (:hour . 20) > ;; (:day . 18) (:month . 7) (:year . 2020)) > ``` It's an interesting approach, but in my experience (having written parsers for probably more than a hundred different time formats), this doesn't really get you very far -- the formats often vary in length, use month names, and so on, so you end up having to write tiny functions for every format. So I'm not sure having something like this in Emacs would help that much. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no