Re: ISO 8601 "Time Intervals" of the "format with time-unit deignators"

From: "Ron Mayer" <ron(at)intervideo(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-patches(at)postgresql(dot)org>
Subject: Re: ISO 8601 "Time Intervals" of the "format with time-unit deignators"
Date: 2003-09-08 18:59:50
Message-ID: POEDIPIPKGJJLDNIEMBEGEAFDJAA.ron@intervideo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-advocacy pgsql-general pgsql-hackers pgsql-patches


Tom wrote:
> "Ron Mayer" <ron(at)intervideo(dot)com> writes:
> > Compared to the ISO 8601 time interval specification, the
> > postgresql interval syntax is quite verbose. For example:
>
> > Postgresql interval: ISO8601 Interval
> > ---------------------------------------------------
> > '1 year 6 months' 'P1Y6M'
> > '3 hours 25 minutes 42 seconds' 'PT3H25M42S'
>
> Er, don't we support that already? I know I saw code to support
> something much like that syntax last time I looked into the datetime
> routines.
>

Nope.

Postgresql supports a rather bizzare shorthand that has a similar
syntax, but AFAICT, doesn't match ISO 8601 in any way that makes
it practical.

A disclaimer, I have the "Final Draft" (ISO/TC 154N 362
of 2000-12-19) of the spec; but have not seen the official,
expensive, version.
ftp://ftp.qsl.net/pub/g1smd/154N362_.PDF

For example, if I read it right, I have differences
like this:

Interval ISO Postgres
8601 shorthand
-----------------------------------------------------
'1 year 1 minute' 'P1YT1M' '1Y1M'
'1 year 1 month' 'P1Y1M' N/A

The best part about the postgresql syntax is that
they omit the required 'P', so it's easy to differentiate
between the two. :-)

Perhaps one could argue that the postgres shorthand should
follow the ISO conventions, but I'd not want to break backward
compatability, incase someone out there is using '1H30M' and
expecting minutes instead of months. If we didn't want to
support two syntaxes, I wouldn't mind eventually depricating
the less-standard one.

Ron

In response to

Responses

Browse pgsql-advocacy by date

  From Date Subject
Next Message Ron Mayer 2003-09-08 19:16:50 Re: ISO 8601 'Time Intervals' of the 'format with time-unit deignators'
Previous Message Kaarel 2003-09-08 18:30:40 Re: About GPL and proprietary software

Browse pgsql-general by date

  From Date Subject
Next Message Ron Mayer 2003-09-08 19:16:50 Re: ISO 8601 'Time Intervals' of the 'format with time-unit deignators'
Previous Message Greg Stark 2003-09-08 18:32:54 Re: why does count take so long?

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeroen Ruigrok/asmodai 2003-09-08 19:00:43 Re: constraint modification on todo list
Previous Message Richard Huxton 2003-09-08 18:48:16 Re: plpgsql debugging

Browse pgsql-patches by date

  From Date Subject
Next Message Ron Mayer 2003-09-08 19:16:50 Re: ISO 8601 'Time Intervals' of the 'format with time-unit deignators'
Previous Message Neil Conway 2003-09-08 18:32:33 Re: mcxt.c