BUG #2599: AM/PM doesn't work in to_timestamp in the middle of a string

Started by Joshua Tolleyover 19 years ago5 messagesbugs
Jump to latest
#1Joshua Tolley
eggyknap@gmail.com

The following bug has been logged online:

Bug reference: 2599
Logged by: Josh Tolley
Email address: eggyknap@gmail.com
PostgreSQL version: 8.1.4
Operating system: Fedora Core 5
Description: AM/PM doesn't work in to_timestamp in the middle of a
string
Details:

eggyknap=# select to_timestamp('30 Aug 06:01:03.223 PM 2006', 'DD Mon
HH:MI:SS.MS AM YYYY'), to_timestamp('30 Aug 2006 06:01:03.223 PM', 'DD Mon
YYYY HH:MI:SS.MS AM');
to_timestamp | to_timestamp
---------------------------+----------------------------
0001-08-30 18:01:03-08 BC | 2006-08-30 18:01:03.223-06

This appears to happen when AM/PM isn't the last element in the string.

#2Bruce Momjian
bruce@momjian.us
In reply to: Joshua Tolley (#1)
Re: BUG #2599: AM/PM doesn't work in to_timestamp in

Josh Tolley wrote:

The following bug has been logged online:

Bug reference: 2599
Logged by: Josh Tolley
Email address: eggyknap@gmail.com
PostgreSQL version: 8.1.4
Operating system: Fedora Core 5
Description: AM/PM doesn't work in to_timestamp in the middle of a
string
Details:

eggyknap=# select to_timestamp('30 Aug 06:01:03.223 PM 2006', 'DD Mon
HH:MI:SS.MS AM YYYY'), to_timestamp('30 Aug 2006 06:01:03.223 PM', 'DD Mon
YYYY HH:MI:SS.MS AM');
to_timestamp | to_timestamp
---------------------------+----------------------------
0001-08-30 18:01:03-08 BC | 2006-08-30 18:01:03.223-06

This appears to happen when AM/PM isn't the last element in the string.

Nice report. The attached patch fixes it, and will be in 8.2. I am not
backpatching because someone might be relying on this behavior.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachments:

/bjm/difftext/x-diffDownload+9-2
#3Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#2)
Re: BUG #2599: AM/PM doesn't work in to_timestamp in

bruce wrote:

Josh Tolley wrote:

The following bug has been logged online:

Bug reference: 2599
Logged by: Josh Tolley
Email address: eggyknap@gmail.com
PostgreSQL version: 8.1.4
Operating system: Fedora Core 5
Description: AM/PM doesn't work in to_timestamp in the middle of a
string
Details:

eggyknap=# select to_timestamp('30 Aug 06:01:03.223 PM 2006', 'DD Mon
HH:MI:SS.MS AM YYYY'), to_timestamp('30 Aug 2006 06:01:03.223 PM', 'DD Mon
YYYY HH:MI:SS.MS AM');
to_timestamp | to_timestamp
---------------------------+----------------------------
0001-08-30 18:01:03-08 BC | 2006-08-30 18:01:03.223-06

This appears to happen when AM/PM isn't the last element in the string.

Nice report. The attached patch fixes it, and will be in 8.2. I am not
backpatching because someone might be relying on this behavior.

Sorry, I attached the wrong patch to the email. This is the right one.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachments:

/bjm/difftext/x-diffDownload+8-8
#4Andrew - Supernews
andrew+nonews@supernews.com
In reply to: Bruce Momjian (#3)
Re: BUG #2599: AM/PM doesn't work in to_timestamp in

On 2006-09-03, Bruce Momjian <bruce@momjian.us> wrote:

Nice report. The attached patch fixes it, and will be in 8.2. I am not
backpatching because someone might be relying on this behavior.

The bug appears to have been introduced just before the 8.1 betas; since
it causes the AM/PM indicator simply to never work except at the end of
the string, I see no possible justification for not backpatching the fix.

--
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services

#5Bruce Momjian
bruce@momjian.us
In reply to: Andrew - Supernews (#4)
Re: BUG #2599: AM/PM doesn't work in to_timestamp in

Backpatched to 8.1.X.

---------------------------------------------------------------------------

Andrew - Supernews wrote:

On 2006-09-03, Bruce Momjian <bruce@momjian.us> wrote:

Nice report. The attached patch fixes it, and will be in 8.2. I am not
backpatching because someone might be relying on this behavior.

The bug appears to have been introduced just before the 8.1 betas; since
it causes the AM/PM indicator simply to never work except at the end of
the string, I see no possible justification for not backpatching the fix.

--
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +