diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-03-03 11:06:47 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-03-03 11:06:47 -0500 |
commit | d67755049388526cd8673aa826dc794b97345eb3 (patch) | |
tree | f713dbf03195f9cf0ed3dd2bb93066a46b706682 /doc/src | |
parent | 1810ca18bfad9072facc548417630115b078483e (diff) | |
download | postgresql-d67755049388526cd8673aa826dc794b97345eb3.tar.gz postgresql-d67755049388526cd8673aa826dc794b97345eb3.zip |
Allow to_date/to_timestamp to recognize non-English month/day names.
to_char() has long allowed the TM (translation mode) prefix to
specify output of translated month or day names; but that prefix
had no effect in input format strings. Now it does. to_date()
and to_timestamp() will now recognize the same month or day names
that to_char() would output for the same format code. Matching is
case-insensitive (per the active collation's notion of what that
means), just as it has always been for English month/day names
without the TM prefix.
(As per the discussion thread, there are lots of cases that this
feature will not handle, such as alternate day names. But being
able to accept what to_char() will output seems useful enough.)
In passing, fix some shaky English and violations of message
style guidelines in jsonpath errors for the .datetime() method,
which depends on this code.
Juan José SantamarÃa Flecha, reviewed and modified by me,
with other commentary from Alvaro Herrera, Tomas Vondra,
Arthur Zakirov, Peter Eisentraut, Mark Dilger.
Discussion: https://postgr.es/m/CAC+AXB3u1jTngJcoC1nAHBf=M3v-jrEfo86UFtCqCjzbWS9QhA@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/func.sgml | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 28035f1635c..323366feb60 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -5968,7 +5968,7 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}'); </row> <row> <entry><literal>TM</literal> prefix</entry> - <entry>translation mode (print localized day and month names based on + <entry>translation mode (use localized day and month names based on <xref linkend="guc-lc-time"/>)</entry> <entry><literal>TMMonth</literal></entry> </row> @@ -5999,9 +5999,20 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}'); <listitem> <para> - <literal>TM</literal> does not include trailing blanks. - <function>to_timestamp</function> and <function>to_date</function> ignore - the <literal>TM</literal> modifier. + <literal>TM</literal> suppresses trailing blanks whether or + not <literal>FM</literal> is specified. + </para> + </listitem> + + <listitem> + <para> + <function>to_timestamp</function> and <function>to_date</function> + ignore letter case in the input; so for + example <literal>MON</literal>, <literal>Mon</literal>, + and <literal>mon</literal> all accept the same strings. When using + the <literal>TM</literal> modifier, case-folding is done according to + the rules of the function's input collation (see + <xref linkend="collation"/>). </para> </listitem> @@ -12824,12 +12835,12 @@ table2-mapping <para> The <literal>datetime()</literal> and <literal>datetime(<replaceable>template</replaceable>)</literal> methods - use the same parsing rules as <literal>to_timestamp</literal> SQL - function does (see <xref linkend="functions-formatting"/>) with three - exceptions. At first, these methods doesn't allow unmatched template - patterns. At second, only following separators are allowed in the - template string: minus sign, period, solidus, comma, apostrophe, - semicolon, colon and space. At third, separators in the template string + use the same parsing rules as the <literal>to_timestamp</literal> SQL + function does (see <xref linkend="functions-formatting"/>), with three + exceptions. First, these methods don't allow unmatched template + patterns. Second, only the following separators are allowed in the + template string: minus sign, period, solidus (slash), comma, apostrophe, + semicolon, colon and space. Third, separators in the template string must exactly match the input string. </para> </note> |