On 06/03/20 22:46, Tom Lane wrote:
> "Isn't quite clear"? ISTM that if the standard intended to allow that,
> it'd be pretty clear. I looked through the 8601 spec just now, and
> I can't see any indication whatever that they intend to allow "-" before P.
Umm, did you see any indication that they intend to allow "-" /anywhere/
in a time interval (with the exception of between year and month, month
and day in the alternate form, as simple delimiters, not as minus?
(Maybe you did; I'm looking at a publicly-accessible 2016 draft.)
It looks like the whole idea of minusness has to be shoehorned into ISO 8601
by anyone who misses it, and that's been done different ways. I guess that's
the "isn't quite clear" part.
> Which "lots of software" are you speaking of, exactly? interval_in
> has never had such a capability, and I don't recall previous complaints
> about it.
Java durations allow both the PostgreSQL-style minus on individual
components, and a leading minus that negates the whole thing. [1]
That explicitly says "The leading plus/minus sign, and negative values
for other units are not part of the ISO-8601 standard."
XML Schema (and therefore XML Query, which uses XML Schema data types)
allows only the leading minus. [2]
The XML Schema folks say their concept is "drawn from those of ISO 8601,
specifically durations without fixed endpoints." That's why they can get
away with just the single leading sign: they don't admit something like
P1M-1D which you don't know to call 27, 28, 29, or 30 days until you're
given an endpoint to hang it on.
I had to deal with that in [3].
Regards,
-Chap
[1]
https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-
[2] https://www.w3.org/TR/xmlschema11-2/#nt-durationRep
[3]
https://github.com/tada/pljava/blob/master/pljava-examples/src/main/java/org/postgresql/pljava/example/saxon/S9.java#L329