1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-12 21:01:52 +03:00

Fix to_date's handling of year 519.

A thinko in commit 029dfdf115 caused the year
519 to be handled differently from either adjacent year, which was not the
intention AFAICS.  Report and diagnosis by Marc Cousin.

In passing, remove redundant re-tests of year value.
This commit is contained in:
Tom Lane
2012-07-02 11:35:24 -04:00
parent 972e066638
commit 8400d31329

View File

@ -1987,20 +1987,20 @@ static int
adjust_partial_year_to_2020(int year)
{
/*
* Adjust all dates toward 2020; this is effectively what happens when we
* Adjust all dates toward 2020; this is effectively what happens when we
* assume '70' is 1970 and '69' is 2069.
*/
/* Force 0-69 into the 2000's */
if (year < 70)
return year + 2000;
/* Force 70-99 into the 1900's */
else if (year >= 70 && year < 100)
else if (year < 100)
return year + 1900;
/* Force 100-519 into the 2000's */
else if (year >= 100 && year < 519)
else if (year < 520)
return year + 2000;
/* Force 520-999 into the 1000's */
else if (year >= 520 && year < 1000)
else if (year < 1000)
return year + 1000;
else
return year;