GNU bug report logs - #52209
28.0.60; [PATCH] date-to-time fails on pure dates

Previous Next

Package: emacs;

Reported by: Bob Rogers <rogers-emacs <at> rgrjr.homedns.org>

Date: Tue, 30 Nov 2021 21:49:02 UTC

Severity: normal

Found in version 28.0.60

Full log


Message #85 received at 52209 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Bob Rogers <rogers-emacs <at> rgrjr.homedns.org>
Cc: 52209 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>,
 Paul Eggert <eggert <at> cs.ucla.edu>
Subject: Re: bug#52209: 28.0.60; [PATCH] date-to-time fails on pure dates
Date: Mon, 03 Jan 2022 12:34:33 +0100
Bob Rogers <rogers-emacs <at> rgrjr.homedns.org> writes:

>    And in that context, it may make more sense to say, "Use the original
> parse-time-string if you know you have email dates, or iso8601-parse if
> you have dates that conform to ISO-8601," rather than having parse-date
> handle them itself.

Yeah.  And rename `parse-time-string' to something less confusing.

>    So how about just adding something that makes parsing common date
>    formats easier, but without being DWIM or being hard-coded . . .
>
>    I think that'd be more generally useful.
>
> Perhaps, but I see that as a different problem:  One where you have a
> date or set of dates in a precise format and just need to knock them
> out.  I was trying to solve the problem where you have date(s) that you
> only know the general origin (e.g. North America) and don't know whether
> they are numeric, alphabetic, or how precise, and just want the parser
> to do the best it can, and signal a reasonably informative error rather
> than return an incorrect result.

Yes, I think a function like that would be welcomed by many...  but
would then lead to an endless series of patches as it'd be extended
because it doesn't work correctly on dates from, say, Iceland.  That is,
a DWIM function would never be finished.

>    On Jan 01 2022, Lars Ingebrigtsen wrote:
>
>    > (parse-time "%Y/%m/%d" "2021/01/01")
>    > => (nil nil nil 01 01 2021)
>
>    Aka strptime.
>
> Oh, you're talking about the POSIX strptime, not the Perl Date::Parse
> strptime, which is free-form.  Not being a C programmer, I was not aware
> of the POSIX version.  But now I know where the odd name came from.  ;-}

POSIX strptime isn't very useful, because if you know the format that
precisely, you might as well just write a regexp for it yourself.  But
something like that, but with more sloppiness (i.e., allowing regexp
matching for the non-time bits) might be useful.  (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.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 3 years and 172 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.