diff options
author | Bruce Momjian <bruce@momjian.us> | 2000-06-09 03:18:34 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2000-06-09 03:18:34 +0000 |
commit | dbf2fd2e0fcba130e1def905464cc002992cac69 (patch) | |
tree | e74d877712effdadce48b95176d039056d8eba97 /src/backend/utils/adt/formatting.c | |
parent | ce7746201b81ba57c0145b631013b13f00a0537a (diff) | |
download | postgresql-dbf2fd2e0fcba130e1def905464cc002992cac69.tar.gz postgresql-dbf2fd2e0fcba130e1def905464cc002992cac69.zip |
The enclosed patch changes the behaviour of the "ordinal" ('TH') format for
to_char. I don't know about the rest of the world, but the "standard" in
Australia is the following:
1st, 2nd, 3rd, 4th - 9th
10th - 19th
21st, 22nd, 23rd, 24th - 29th (similarly for 30s - 90s)
110th - 119th (and for all "teens")
121st, 122nd, 123rd, 124th - 129th
I think you see the trend. The current code works fine except that it
produces:
111st, 112nd, 113rd, 114th - 119th
211st, 212nd, 213rd, 214th - 219th ... and so on.
Without knowing anything about what's supported (and what isn't) in the usual
I18N libraries, should this type of behaviour be defined within the locales?
Daniel Baldoni
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r-- | src/backend/utils/adt/formatting.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 82fce58ad34..19cbd8ef209 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.10 2000/06/09 01:11:08 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.11 2000/06/09 03:18:34 momjian Exp $ * * * Portions Copyright (c) 1999-2000, PostgreSQL, Inc @@ -1258,14 +1258,17 @@ static char * get_th(char *num, int type) { int len = strlen(num), - last; + last, seclast; last = *(num + (len - 1)); if (!isdigit((unsigned char) last)) elog(ERROR, "get_th: '%s' is not number.", num); - /* 11 || 12 */ - if (len == 2 && (last == '1' || last == '2') && *num == '1') + /* + * All "teens" (<x>1[0-9]) get 'TH/th', + * while <x>[02-9][123] still get 'ST/st', 'ND/nd', 'RD/rd', respectively + */ + if ((len > 1) && ((seclast = num[len-2]) == '1')) last = 0; switch (last) |