Subject: bug#52209: 28.0.60; [PATCH] date-to-time fails on pure dates

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 03 Jan 2022 12:34:33 +0100

Bob Rogers <[email-masked]> 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