Re: ISO week dates

From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Alban Hertroys" <alban(at)magproductions(dot)nl>
Cc: "Bruce Momjian" <bruce(at)momjian(dot)us>, "Peter Eisentraut" <peter_e(at)gmx(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: ISO week dates
Date: 2006-11-23 12:08:47
Message-ID: 37ed240d0611230408u1c651461mae16a50f82495b5f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

On 11/23/06, Alban Hertroys <alban(at)magproductions(dot)nl> wrote:
> Bruce Momjian wrote:
> > Peter Eisentraut wrote:
> >> Brendan Jurd wrote:
> >>> * add an ISO day format pattern to to_char() called 'ID', which
> >>> starts at Monday = 1, and
> >>> * add an ISO year field to extract() called 'isoyear'?
> >> That seems reasonable. Do you volunteer?
> >
> > Added to TODO:
> >
> > * Add ISO day of week format 'ID' to to_char() where Monday = 1
> > * Add an ISO year field to extract() called 'isoyear'
>
> Just verifying, but aren't both formats ISO? In that case maybe it'd be
> better to have a (per database) setting that specifies which one?

The term "ISO" is broad and perhaps a little misleading. ISO 8601
specifies many date and time formats, of which the "week date" is one.
The field I have tentatively named "isoyear" refers to the year,
according to the ISO week date calendar, which is similar to, but
distinct from, the Gregorian calendar.

I'm not particularly attached to the name "isoyear". If that is seen
as too vague, perhaps "weekyear" or something similar would work
better. It can easily be changed at this stage.

ISO 8601 provides for dates expressed in the Gregorian style and the
week date style. What I have tried to achieve with this patch, is to
allow users of Postgres to {specify|describe|operate on} dates in
either the Gregorian or week date calendars, as they prefer. It
really depends on context whether the Gregorian or week date is more
desirable.

As far as I know, the standard only provides for one numeric
representation of the "day of week", which begins the week at Monday =
1 and ends at Sunday = 7. Other conventions currently supported in
Postgres, such as Sunday = 0 or Sunday = 1, are to my knowledge
non-ISO. Hence the addition of 'ID' to the formatting functions.

I hope that provides some added clarity.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tino Wildenhain 2006-11-23 12:37:02 Re: URL Decoding
Previous Message Greg Sabino Mullane 2006-11-23 12:07:11 Re: Trapping PL/Perl spi_query_exec errors

Browse pgsql-patches by date

  From Date Subject
Next Message Alban Hertroys 2006-11-23 13:15:03 Re: ISO week dates
Previous Message Alban Hertroys 2006-11-23 08:44:14 Re: ISO week dates