Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-advocacypgsql-generalpgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-patches by date

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

pgsql-advocacy by date

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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group