Re: [HACKERS] ISO dates with European Format

Поиск
Список
Период
Сортировка
От Thomas Lockhart
Тема Re: [HACKERS] ISO dates with European Format
Дата
Msg-id 37DE5DD1.97671019@alumni.caltech.edu
обсуждение исходный текст
Ответ на ISO dates with European Format  (Theo Kramer <theo@flame.co.za>)
Список pgsql-hackers
> > What is "ISO dates with European format"? Is it a combination of ISO
> > date output with European-style input (which I think can be done
> > already), or something else? afaik ISO-8601 is specific about
> > suggested formats, and makes no distinction between European and other
> > conventions. Can you give examples? TIA
>   coza=> set datestyle to 'SQL,European';
>   ...
>   02/06/1997 00:00:00.00 SAST
> The above result is correct for dd/mm/yyyy styles
>   coza=> set datestyle to 'ISO,European';
>   ...
>   1997-06-02 00:00:00+02
> Instead of 02-06-1997 00:00:00+02
> If ISO is specific regarding formatting of days, month and year then I feel that
> the "set datestyle to 'ISO,European'" should give an error. However, I would
> personally prefer it to format the result as "dd-mm-yyyy".

Ah! The yyyy-mm-dd order is specified by ISO-8601. wrt Postgres, you
are actually wanting European format with "-" as a date delimiter,
rather than the "/".

As an aside, "ISO,European" does actually have meaning, since setting
the DateStyle to ISO only fully constrains the output format, but
"European" helps the date parser resolve free-form date input
ambiguities by assuming European, rather than US, conventions for
ordering of input fields.

But back to the delimiter...

Date conventions between and among countries vary. The formats we
currently have each meet the conventions of multiple countries (not
certain about "German", since apparently other Germanic countries do
not all share the same convention). There are (at least) two things we
could do:

1) Parameterize the delimiter field using a #define constant you can
redefine in Makefile.global, Makefile.custom, or configure. Apparently
South Africa uses the "-" convention for date delimiters? Or is this a
more local or project-specific preference??

2) Parameterize the delimiter as a global character variable, which
can be manipulated by something like "set DateDelimiter = '-'". This
is a little nervous-making for me, since you (and every database user)
would have the ability to modify the date format to something that
Postgres can not read. So we would have to modify the input routines
to accept an arbitrary delimiter, as well as the conventional
delimiters (both "-" and "/") already recognized. I suppose we could
put constraints on the "set DateDelimiter" values to help protect from
this...

You could also consider massaging the date format as it is displayed
by your app, since that would give you full control over the
appearance.
                    - Thomas

-- 
Thomas Lockhart                lockhart@alumni.caltech.edu
South Pasadena, California


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Performance of MIN() and MAX()
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] serial type