Re: ISO 8601 "Time Intervals" of the "format with time-unit deignators" - Mailing list pgsql-patches

From Ron Mayer
Subject Re: ISO 8601 "Time Intervals" of the "format with time-unit deignators"
Date
Msg-id POEDIPIPKGJJLDNIEMBEGEAFDJAA.ron@intervideo.com
Whole thread Raw
In response to Re: ISO 8601 "Time Intervals" of the "format with time-unit deignators"  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: ISO 8601 "Time Intervals" of the "format with time-unit deignators"
List pgsql-patches
Tom wrote:
> "Ron Mayer" <ron@intervideo.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



pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: mcxt.c
Next
From: "Ron Mayer"
Date:
Subject: Re: ISO 8601 'Time Intervals' of the 'format with time-unit deignators'