unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Allow unspecified dates in iso8601-valid-p?
@ 2022-07-04 12:47 Joost Kremers
  2022-07-04 15:34 ` Bob Rogers
  0 siblings, 1 reply; 4+ messages in thread
From: Joost Kremers @ 2022-07-04 12:47 UTC (permalink / raw)
  To: emacs-devel

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.

The reason behind this request is that `bibtex.el`, when creating a key for an
entry, checks the date field against `iso8601-valid-p` and errors out if it
finds an invalid date. Problem is that sometimes publication dates simply are
not known or cannot be given, which is exactly the kind of reason why the
unspecified date extension to ISO8601 exists.

One option would be to add an additional argument to `iso8601-valid-p` that
indicates whether to allow unspecified dates or not, but in that case,
`bibtex.el` would have to be adjusted as well.

TIA

Joost


-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Allow unspecified dates in iso8601-valid-p?
  2022-07-04 12:47 Allow unspecified dates in iso8601-valid-p? Joost Kremers
@ 2022-07-04 15:34 ` Bob Rogers
  2022-07-04 16:21   ` Joost Kremers
  0 siblings, 1 reply; 4+ messages in thread
From: Bob Rogers @ 2022-07-04 15:34 UTC (permalink / raw)
  To: Joost Kremers; +Cc: emacs-devel

   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/



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Allow unspecified dates in iso8601-valid-p?
  2022-07-04 15:34 ` Bob Rogers
@ 2022-07-04 16:21   ` Joost Kremers
  2022-07-04 16:56     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Joost Kremers @ 2022-07-04 16:21 UTC (permalink / raw)
  To: Bob Rogers; +Cc: emacs-devel


On Mon, Jul 04 2022, Bob Rogers wrote:
> 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.

Ok, I see your point.

>    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.

The question then becomes if it's useful to write such a function, or would it
make more sense to account for unspecified dates in the relevant part of
bibtex.el.



-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Allow unspecified dates in iso8601-valid-p?
  2022-07-04 16:21   ` Joost Kremers
@ 2022-07-04 16:56     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2022-07-04 16:56 UTC (permalink / raw)
  To: Joost Kremers; +Cc: Bob Rogers, emacs-devel

> The question then becomes if it's useful to write such a function, or would it
> make more sense to account for unspecified dates in the relevant part of
> bibtex.el.

Not sure where it should live, but it could start with a hack like

    (defun iso8601-compilant-p (date)
      (iso8601-valid-p (replace-regexp-in-string "[xX]" "1" date)))


-- Stefan




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-04 16:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-04 12:47 Allow unspecified dates in iso8601-valid-p? Joost Kremers
2022-07-04 15:34 ` Bob Rogers
2022-07-04 16:21   ` Joost Kremers
2022-07-04 16:56     ` Stefan Monnier

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).