Re: Allow to_date() and to_timestamp() to accept localized names
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mark Dilger <mark.dilger@enterprisedb.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>, Alvaro Herrera <alvherre@2ndquadrant.com>, Arthur Zakirov <zaartur@gmail.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-01-28T19:37:50Z
Lists: pgsql-hackers
Mark Dilger <mark.dilger@enterprisedb.com> writes:
>> On Jan 28, 2020, at 9:30 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> A brute-force answer, if there are few enough cases, is to recognize
>> them regardless of the specific value of LC_TIME. Do we think
>> anybody would notice or care if to_date('Sonnabend', 'TMDay') works
>> even when in a non-German locale?
> I think this only becomes a problem if there are weekday or month name collisions between languages where they have different meanings. As an absurd hypothetical, if “Sunday” in Tagalog means what “Tuesday” means in English, then you’ve got a problem.
> This does happen for month abbreviations. “Mar” is short for “March” and variations in a number of languages, but short for “November” in Finnish.
> For day abbreviations, “Su” collides between fi_FI and hr_HR, and “tor” collides between sl_SL and no_NO.
But none of those cases are alternative names, so we wouldn't have
entries for them in this hypothetical list. They'd only be recognized
when strftime() returns them. I suspect also that the abbreviated
names have few if any alternatives, so we may only need this whole hack
for full names.
A possible way of tightening things up without explicitly decoding the
locale name is to make the entries of the list be string pairs: "if
strftime() returned this, then also consider that". That puts a bit
of a premium on knowing which names strftime considers primary, but
I think we'd have had to know that anyway.
regards, tom lane
Commits
-
Allow to_date/to_timestamp to recognize non-English month/day names.
- d67755049388 13.0 landed
-
Clean up formatting.c's logic for matching constant strings.
- fb12aefaafce 11.7 landed
- be13f227febc 12.2 landed
- a576f2a8f2e8 9.5.21 landed
- 9e24575f6f1b 9.6.17 landed
- 600b953d73ca 9.4.26 landed
- 212b870d6743 10.12 landed
- 4c70098ffa8c 13.0 landed
-
Implement standard datetime parsing mode
- 1a950f37d0a2 13.0 cited
-
Repair assorted issues in locale data extraction.
- 7ad1cd31bfcb 12.0 cited