Re: [GENERAL] ISO week dates

Поиск
Список
Период
Сортировка
От Guillaume Lelarge
Тема Re: [GENERAL] ISO week dates
Дата
Msg-id 452E1ADA.60207@lelarge.info
обсуждение исходный текст
Ответы Re: [GENERAL] ISO week dates  (Heikki Linnakangas <heikki@enterprisedb.com>)
Re: [GENERAL] ISO week dates  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-patches
Peter Eisentraut a ecrit le 07/10/2006 09:01:
> 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?
>

I've tried to work on the first one, the ISO day field. My patch is
attached and is against CVS HEAD. It only takes care of the code,
nothing is done for documentation matter. It works with me :

toto=# select to_char(('2006-10-'||a+2)::date, 'DAY') as "dow",
   to_char(('2006-10-'||a+2)::date, 'ID') as "ID field",
   to_char(('2006-10-'||a+2)::date, 'D') as "D field"
   from generate_series(1, 15) as a;
     dow    | ID field | D field
-----------+----------+---------
  TUESDAY   | 2        | 3
  WEDNESDAY | 3        | 4
  THURSDAY  | 4        | 5
  FRIDAY    | 5        | 6
  SATURDAY  | 6        | 7
  SUNDAY    | 7        | 1
  MONDAY    | 1        | 2
  TUESDAY   | 2        | 3
  WEDNESDAY | 3        | 4
  THURSDAY  | 4        | 5
  FRIDAY    | 5        | 6
  SATURDAY  | 6        | 7
  SUNDAY    | 7        | 1
  MONDAY    | 1        | 2
  TUESDAY   | 2        | 3
(15 rows)

I just want to know if my patch is interesting... and if it's OK, I can
work on the ISO year field.

Regards.


--
Guillaume.
Index: src/backend/utils/adt/formatting.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/formatting.c,v
retrieving revision 1.113
diff -r1.113 formatting.c
555a556
>     DCH_ID,
599a601
>     DCH_id,
698c700,701
<     {"IW", 2, dch_date, DCH_IW, TRUE},    /* I */
---
>     {"ID", 2, dch_date, DCH_ID, TRUE},    /* I */
>     {"IW", 2, dch_date, DCH_IW, TRUE},
742c745,746
<     {"iw", 2, dch_date, DCH_IW, TRUE},    /* i */
---
>     {"id", 2, dch_date, DCH_ID, TRUE},    /* i */
>     {"iw", 2, dch_date, DCH_IW, TRUE},
832c836
<     DCH_FX, -1, DCH_HH24, DCH_IW, DCH_J, -1, -1, DCH_MI, -1, -1,
---
>     DCH_FX, -1, DCH_HH24, DCH_ID, DCH_J, -1, -1, DCH_MI, -1, -1,
835c839
<     DCH_day, -1, DCH_fx, -1, DCH_hh24, DCH_iw, DCH_j, -1, -1, DCH_mi,
---
>     DCH_day, -1, DCH_fx, -1, DCH_hh24, DCH_id, DCH_j, -1, -1, DCH_mi,
2369a2374
>         case DCH_ID:
2373c2378,2381
<                 sprintf(inout, "%d", tm->tm_wday + 1);
---
>                 if (arg == DCH_D)
>                     sprintf(inout, "%d", tm->tm_wday + 1);
>                 else
>                     sprintf(inout, "%d", (tm->tm_wday == 0) ? 7 : tm->tm_wday);
2380a2389,2390
>                 if (arg == DCH_ID && tmfc->d == 7)
>                     tmfc->d = 0;

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

Предыдущее
От: "Hiroshi Saito"
Дата:
Сообщение: warning: "min" redefined of qsort.
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: [GENERAL] ISO week dates