unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: "Guu, Jin-Cheng" <jcguu95@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Shorter and more flexible implementation for parse-time.el
Date: Sat, 24 Jul 2021 14:12:25 +0200	[thread overview]
Message-ID: <87mtqb3o7q.fsf@gnus.org> (raw)
In-Reply-To: <CAErjG5cqB4_-__kQjKmgb_RW+-kHFtOyUpCdGF+-AoWb_bKPRw@mail.gmail.com> (Jin-Cheng Guu's message of "Fri, 23 Jul 2021 12:03:33 -0500")

"Guu, Jin-Cheng" <jcguu95@gmail.com> 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



  reply	other threads:[~2021-07-24 12:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-23 17:03 Shorter and more flexible implementation for parse-time.el Guu, Jin-Cheng
2021-07-24 12:12 ` Lars Ingebrigtsen [this message]
2021-07-24 15:03   ` Guu, Jin-Cheng
2021-07-25  6:34     ` Lars Ingebrigtsen
2021-07-25  9:38       ` Guu, Jin-Cheng
2021-07-25  9:58         ` Yuri Khan
2021-07-25 10:14           ` Arthur Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mtqb3o7q.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=emacs-devel@gnu.org \
    --cc=jcguu95@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).