Commit 65b731bd authored by Bruce Momjian's avatar Bruce Momjian

Fix to_timestamp() to not require upper/lower case matching for meridian

designations (AM/PM).  Also separate out matching of a meridian with
periods (e.g. A.M.) and with those without.

Do the same for AD/BC.

Brendan Jurd
parent b75b6633
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.471 2009/02/06 21:15:11 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.472 2009/02/07 14:16:45 momjian Exp $ -->
<chapter id="functions">
<title>Functions and Operators</title>
......@@ -4867,14 +4867,14 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
<entry>seconds past midnight (0-86399)</entry>
</row>
<row>
<entry><literal>AM</literal> or <literal>A.M.</literal> or
<literal>PM</literal> or <literal>P.M.</literal></entry>
<entry>meridian indicator (uppercase)</entry>
<entry><literal>AM</literal>, <literal>am</literal>,
<literal>PM</literal> or <literal>pm</literal></entry>
<entry>meridiem indicator (without periods)</entry>
</row>
<row>
<entry><literal>am</literal> or <literal>a.m.</literal> or
<literal>pm</literal> or <literal>p.m.</literal></entry>
<entry>meridian indicator (lowercase)</entry>
<entry><literal>A.M.</literal>, <literal>a.m.</literal>,
<literal>P.M.</literal> or <literal>p.m.</literal></entry>
<entry>meridiem indicator (with periods)</entry>
</row>
<row>
<entry><literal>Y,YYY</literal></entry>
......@@ -4913,14 +4913,14 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
<entry>last digit of ISO year</entry>
</row>
<row>
<entry><literal>BC</literal> or <literal>B.C.</literal> or
<literal>AD</literal> or <literal>A.D.</literal></entry>
<entry>era indicator (uppercase)</entry>
<entry><literal>BC</literal>, <literal>bc</literal>,
<literal>AD</literal> or <literal>ad</literal></entry>
<entry>era indicator (without periods)</entry>
</row>
<row>
<entry><literal>bc</literal> or <literal>b.c.</literal> or
<literal>ad</literal> or <literal>a.d.</literal></entry>
<entry>era indicator (lowercase)</entry>
<entry><literal>B.C.</literal>, <literal>b.c.</literal>,
<literal>A.D.</literal> or <literal>a.d.</literal></entry>
<entry>era indicator (with periods)</entry>
</row>
<row>
<entry><literal>MONTH</literal></entry>
......
This diff is collapsed.
......@@ -2740,13 +2740,13 @@ SELECT '' AS to_timestamp_5, to_timestamp('1,582nd VIII 21', 'Y,YYYth FMRM DD');
(1 row)
SELECT '' AS to_timestamp_6, to_timestamp('15 "text between quote marks" 98 54 45',
E'HH "\\text between quote marks\\"" YY MI SS');
E'HH24 "\\text between quote marks\\"" YY MI SS');
to_timestamp_6 | to_timestamp
----------------+------------------------------
| Thu Jan 01 15:54:45 1998 PST
(1 row)
SELECT '' AS to_timestamp_7, to_timestamp('05121445482000', 'MMDDHHMISSYYYY');
SELECT '' AS to_timestamp_7, to_timestamp('05121445482000', 'MMDDHH24MISSYYYY');
to_timestamp_7 | to_timestamp
----------------+------------------------------
| Fri May 12 14:45:48 2000 PDT
......@@ -2759,7 +2759,7 @@ SELECT '' AS to_timestamp_8, to_timestamp('2000January09Sunday', 'YYYYFMMonthDDF
(1 row)
SELECT '' AS to_timestamp_9, to_timestamp('97/Feb/16', 'YYMonDD');
ERROR: invalid value for "Mon" in source string
ERROR: invalid value "/Fe" for "Mon"
DETAIL: The given value did not match any of the allowed values for this field.
SELECT '' AS to_timestamp_10, to_timestamp('19971116', 'YYYYMMDD');
to_timestamp_10 | to_timestamp
......@@ -2847,7 +2847,7 @@ DETAIL: Field requires 2 characters, but only 1 remain.
HINT: If your source string is not fixed-width, try using the "FM" modifier.
-- Insufficient digit characters for a single node:
SELECT '' AS to_timestamp_24, to_timestamp('19971)24', 'YYYYMMDD');
ERROR: invalid value for "MM" in source string
ERROR: invalid value "1)" for "MM"
DETAIL: Field requires 2 characters, but only 1 could be parsed.
HINT: If your source string is not fixed-width, try using the "FM" modifier.
-- Value clobbering:
......@@ -2856,7 +2856,7 @@ ERROR: conflicting values for "Mon" field in formatting string
DETAIL: This value contradicts a previous setting for the same field type.
-- Non-numeric input:
SELECT '' AS to_timestamp_26, to_timestamp('199711xy', 'YYYYMMDD');
ERROR: invalid value for "DD" in source string
ERROR: invalid value "xy" for "DD"
DETAIL: Value must be an integer.
-- Input that doesn't fit in an int:
SELECT '' AS to_timestamp_27, to_timestamp('10000000000', 'FMYYYY');
......
......@@ -391,9 +391,9 @@ SELECT '' AS to_timestamp_4, to_timestamp('My birthday-> Year: 1976, Month: May,
SELECT '' AS to_timestamp_5, to_timestamp('1,582nd VIII 21', 'Y,YYYth FMRM DD');
SELECT '' AS to_timestamp_6, to_timestamp('15 "text between quote marks" 98 54 45',
E'HH "\\text between quote marks\\"" YY MI SS');
E'HH24 "\\text between quote marks\\"" YY MI SS');
SELECT '' AS to_timestamp_7, to_timestamp('05121445482000', 'MMDDHHMISSYYYY');
SELECT '' AS to_timestamp_7, to_timestamp('05121445482000', 'MMDDHH24MISSYYYY');
SELECT '' AS to_timestamp_8, to_timestamp('2000January09Sunday', 'YYYYFMMonthDDFMDay');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment