Datetime input-parsing shortcoming

Started by Tom Laneabout 27 years ago2 messageshackers
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

Seen with current sources and with 6.4.2:

When datestyle = 'Postgres,European', the datetime parser will accept
dates written in either US or Euro order:

regression=> set datestyle = 'Postgres,European';
SET VARIABLE
regression=> select 'Wed 06 Jan 16:10:00 1999 EST'::datetime;
?column?
----------------------------
Wed 06 Jan 16:10:00 1999 EST
(1 row)

regression=> select 'Wed Jan 06 16:10:00 1999 EST'::datetime;
?column?
----------------------------
Wed 06 Jan 16:10:00 1999 EST
(1 row)

But when datestyle = 'Postgres,US' it won't:

regression=> set datestyle = 'Postgres,US';
SET VARIABLE
regression=> select 'Wed Jan 06 16:10:00 1999 EST'::datetime;
?column?
----------------------------
Wed Jan 06 16:10:00 1999 EST
(1 row)
regression=> select 'Wed 06 Jan 16:10:00 1999 EST'::datetime;
ERROR: Bad datetime external representation 'Wed 06 Jan 16:10:00 1999 EST'

A bug, no??

regards, tom lane

#2Thomas Lockhart
lockhart@alumni.caltech.edu
In reply to: Tom Lane (#1)
Re: [HACKERS] Datetime input-parsing shortcoming

Seen with current sources and with 6.4.2:
When datestyle = 'Postgres,European', the datetime parser will accept
dates written in either US or Euro order:
But when datestyle = 'Postgres,US' it won't:
regression=> select 'Wed 06 Jan 16:10:00 1999 EST'::datetime;
ERROR: Bad datetime external representation
A bug, no??

Si, though I would prefer to think of it as a "feature omission" since
it would have accepted a date sometimes (if the day of month was greater
than 12) :)

postgres=> show DateStyle;
NOTICE: DateStyle is Postgres with US (NonEuropean) conventions
postgres=> select 'Wed 06 Jan 16:10:00 1999 EST'::datetime;
----------------------------
Wed Jan 06 21:10:00 1999 GMT
(1 row)

Will apply to the development tree soon...

- Tom

Attachments:

dt.c.patchtext/plain; charset=us-ascii; name=dt.c.patchDownload+24-17