emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Allow unspecified dates in iso8601-valid-p?


From: Bob Rogers
Subject: Allow unspecified dates in iso8601-valid-p?
Date: Mon, 4 Jul 2022 11:34:49 -0400

   From: Joost Kremers <joostkremers@fastmail.fm>
   Date: Mon, 04 Jul 2022 14:47:08 +0200

   Hi list,

   The function `iso8601-valid-p` can be used to check if a string
   constitutes a valid ISO8601-formatted date. It seems that ISO8601 is
   a big spec with several modifications and extensions, so I'm sure
   it's hardly doable to support everything the spec allows, but I'm
   wondering if it would be possible to allow unspecified dates.

   The relevant spec is described here:

   https://www.datafix.com.au/BASHing/2020-02-12.html

   (There are several parts here, the one I'm referring to is under
   "Unspecified").  It explains that a capital X can be used to indicate
   parts of a date that are unspecified, i.e., "20XX" for a year in the
   21st century . . .

Parsing such dates would seem to require a fair amount of work, as the
design of iso8601.el does not consider partially-specified date values.
What is more, the return value is in terms of decoded time objects,
which can only describe them as either present or absent.

   But if you only want to test ISO 8601 compliance, then ISTM it would
be better (and much easier) to write a new and completely separate
`iso8601-compliant-p` predicate for that purpose, since the charter of
`iso8601-valid-p` is to tell whether iso8601.el can parse something.

                                        -- Bob Rogers
                                           http://www.rgrjr.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]