Re: [HACKERS] DATE type output does not follow datestyle parameter

2014-02-12 Thread Bruce Momjian
On Wed, Feb 12, 2014 at 10:08:26PM +0900, MauMau wrote:
> From: "Bruce Momjian" 
> >On Mon, Dec  2, 2013 at 10:22:47PM +0900, MauMau wrote:
> >>So, my suggestion is to just add the following sentence right after
> >>the above one.
> >>
> >>The Postgres style is an exception: the output of the date type is
> >>either MM-DD- (e.g. 12-17-1997) or DD-MM- (e.g. 17-12-1997),
> >>which is different from the date part of the output of the timestamp
> >>type.
> >>
> >>Could you consider and add this to the manual?
> >
> >Yes, I will make the change unless someone objects.
> 
> Could you commit this if you feel okay?  I'm sorry if I missed the
> modified article in the devel doc.

OK, attached doc patch applied to head and 9.3.  Thanks for the report.

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

  + Everyone has their own god. +
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
new file mode 100644
index b7d7d80..30fd9bb
*** a/doc/src/sgml/datatype.sgml
--- b/doc/src/sgml/datatype.sgml
*** January 8 04:05:06 1999 PST
*** 2205,2212 
   historical accident.)   shows examples of each
   output style.  The output of the date and
!  time types is of course only the date or time part
!  in accordance with the given examples.
  
  
   
--- 2205,2214 
   historical accident.)   shows examples of each
   output style.  The output of the date and
!  time types is generally only the date or time part
!  in accordance with the given examples.  However, the
!  POSTGRES style outputs date-only values in
!  ISO format.
  
  
   

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] DATE type output does not follow datestyle parameter

2014-02-12 Thread MauMau

From: "Bruce Momjian" 

On Mon, Dec  2, 2013 at 10:22:47PM +0900, MauMau wrote:

So, my suggestion is to just add the following sentence right after
the above one.

The Postgres style is an exception: the output of the date type is
either MM-DD- (e.g. 12-17-1997) or DD-MM- (e.g. 17-12-1997),
which is different from the date part of the output of the timestamp
type.

Could you consider and add this to the manual?


Yes, I will make the change unless someone objects.


Could you commit this if you feel okay?  I'm sorry if I missed the modified 
article in the devel doc.


Regards
MauMau



--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] DATE type output does not follow datestyle parameter

2013-12-02 Thread Bruce Momjian
On Mon, Dec  2, 2013 at 10:22:47PM +0900, MauMau wrote:
> I'm sorry I didn't respond for a long time.  I've come up with a suggestion.
> 
> The original reporter of this problem expected the output of the
> date type in 'Postgres,DMY' style to be "17 Dec 1997", when the
> output of the timestamp if "Wed 17 Dec 07:37:16 1997 PST".  He
> thought so by reading the following sentence:
> 
> http://www.postgresql.org/docs/current/static/datatype-datetime.html
> The output of the date and time types is of course only the date or
> time part in accordance with the given examples.
> 
> However, the actual output of the date type in Postgres style is:
> 
> * 12-17-1997 if datestyle is 'Postgres,YMD' or 'Postgres,MDY'
> * 17-12-1997 if datestyle is 'Postgres,DMY'
> 
> So, my suggestion is to just add the following sentence right after
> the above one.
> 
> The Postgres style is an exception: the output of the date type is
> either MM-DD- (e.g. 12-17-1997) or DD-MM- (e.g. 17-12-1997),
> which is different from the date part of the output of the timestamp
> type.
> 
> Could you consider and add this to the manual?

Yes, I will make the change unless someone objects.

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

  + Everyone has their own god. +


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] DATE type output does not follow datestyle parameter

2013-12-02 Thread MauMau

Hi, Bruce san,

From: "Bruce Momjian" 

On Tue, Aug  6, 2013 at 12:09:53PM -0400, Tom Lane wrote:

Yes.  I don't see any reason to change it, either, as nobody has
complained that it's actually bad.  If you feel a compulsion to
change the docs, do that.


OK, seems 'Postgres' is a unique output format for 'date' too, even though
it doesn't look like the 'Postgres' timestamp output:

default
SET datestyle = 'ISO, MDY'; SELECT current_timestamp, current_date;
SET
  now  |date
---+
2013-08-06 16:18:48.218555-04 | 2013-08-06

SET datestyle = 'SQL, MDY'; SELECT current_timestamp, current_date;
SET
  now   |date
+
08/06/2013 16:18:43.054488 EDT | 08/06/2013

SET datestyle = 'German, MDY'; SELECT current_timestamp, current_date;
SET
  now   |date
+
06.08.2013 16:18:59.026553 EDT | 06.08.2013

MDY
SET datestyle = 'Postgres, MDY'; SELECT current_timestamp, current_date;
SET
 now |date
-+
Tue Aug 06 16:18:53.590548 2013 EDT | 08-06-2013

DMY
SET datestyle = 'Postgres, DMY'; SELECT current_timestamp, current_date;
SET
 now |date
-+
Tue 06 Aug 16:20:23.902549 2013 EDT | 06-08-2013

I don't think there is even a documentation change I can suggest.


I'm sorry I didn't respond for a long time.  I've come up with a suggestion.

The original reporter of this problem expected the output of the date type 
in 'Postgres,DMY' style to be "17 Dec 1997", when the output of the 
timestamp if "Wed 17 Dec 07:37:16 1997 PST".  He thought so by reading the 
following sentence:


http://www.postgresql.org/docs/current/static/datatype-datetime.html
The output of the date and time types is of course only the date or time 
part in accordance with the given examples.


However, the actual output of the date type in Postgres style is:

* 12-17-1997 if datestyle is 'Postgres,YMD' or 'Postgres,MDY'
* 17-12-1997 if datestyle is 'Postgres,DMY'

So, my suggestion is to just add the following sentence right after the 
above one.


The Postgres style is an exception: the output of the date type is either 
MM-DD- (e.g. 12-17-1997) or DD-MM- (e.g. 17-12-1997), which is 
different from the date part of the output of the timestamp type.


Could you consider and add this to the manual?

Regards
MauMau





--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] DATE type output does not follow datestyle parameter

2013-08-06 Thread Bruce Momjian
On Tue, Aug  6, 2013 at 12:09:53PM -0400, Tom Lane wrote:
> Bruce Momjian  writes:
> > Is this format so old that we can't fix this?
> 
> Yes.  I don't see any reason to change it, either, as nobody has
> complained that it's actually bad.  If you feel a compulsion to
> change the docs, do that.

OK, seems 'Postgres' is a unique output format for 'date' too, even though
it doesn't look like the 'Postgres' timestamp output:

default 
SET datestyle = 'ISO, MDY'; SELECT current_timestamp, current_date;
SET
  now  |date
---+
 2013-08-06 16:18:48.218555-04 | 2013-08-06

SET datestyle = 'SQL, MDY'; SELECT current_timestamp, current_date;
SET
  now   |date
+
 08/06/2013 16:18:43.054488 EDT | 08/06/2013

SET datestyle = 'German, MDY'; SELECT current_timestamp, current_date;
SET
  now   |date
+
 06.08.2013 16:18:59.026553 EDT | 06.08.2013

MDY 
SET datestyle = 'Postgres, MDY'; SELECT current_timestamp, current_date;
SET
 now |date
-+
 Tue Aug 06 16:18:53.590548 2013 EDT | 08-06-2013

DMY 
SET datestyle = 'Postgres, DMY'; SELECT current_timestamp, current_date;
SET
 now |date
-+
 Tue 06 Aug 16:20:23.902549 2013 EDT | 06-08-2013

I don't think there is even a documentation change I can suggest.

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

  + It's impossible for everything to be true. +



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] DATE type output does not follow datestyle parameter

2013-08-06 Thread Tom Lane
Bruce Momjian  writes:
> Is this format so old that we can't fix this?

Yes.  I don't see any reason to change it, either, as nobody has
complained that it's actually bad.  If you feel a compulsion to
change the docs, do that.

regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] DATE type output does not follow datestyle parameter

2013-08-06 Thread Robert Haas
On Tue, Aug 6, 2013 at 11:40 AM, Bruce Momjian  wrote:
> Yes, you are correct, this is inconsistent.  Let me look at writing a
> patch to fix this.  Is this format so old that we can't fix this?

I think I would be more inclined to change the documentation than the behavior.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] DATE type output does not follow datestyle parameter

2013-08-06 Thread Bruce Momjian
On Wed, Jul 24, 2013 at 09:06:30PM +0900, MauMau wrote:
> Hello,
> 
> The description of datestyle parameter does not seem to match the
> actual behavior.  Is this a bug to be fixed?  Which do you think
> should be corrected, the program or the manual?
> 
> 
> The manual says:
> 
> DateStyle (string)
> Sets the display format for date and time values, as well as the
> rules for interpreting ambiguous date input values. For historical
> reasons, this variable contains two independent components: the
> output format specification (ISO, Postgres, SQL, or German) and the
> input/output specification for year/month/day ordering (DMY, MDY, or
> YMD). ...
> 
> 
> And says:
> 
> http://www.postgresql.org/docs/current/static/datatype-datetime.html
> 
> 8.5.2. Date/Time Output
> The output of the date and time types is of course only the date or
> time part in accordance with the given examples.
> 
> 
> After doing "SET datestyle = 'Postgres, MDY'" on the psql prompt, I
> did the following things on the same psql session:
> 
> 
> 1. SELECT current_timestamp;
> 
>   now
> --
> Wed Jul 24 10:51:00.217 2013 GMT
> (1 行)
> 
> This is exactly as I expected.
> 
> 
> 2. SELECT current_date;
> I expected the output "Wed Jul 24 2013" or "Jul 24 2013", but I got:
> 
>date
> 
> 07-24-2013
> (1 行)
> 
> This does not follow the above statement in 8.5.2.  This output is
> created by EncodeDateOnly() in src/backend/utils/adt/datetime.c.

Yes, you are correct, this is inconsistent.  Let me look at writing a
patch to fix this.  Is this format so old that we can't fix this?

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

  + It's impossible for everything to be true. +


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] DATE type output does not follow datestyle parameter

2013-07-24 Thread MauMau

Hello,

The description of datestyle parameter does not seem to match the actual 
behavior.  Is this a bug to be fixed?  Which do you think should be 
corrected, the program or the manual?



The manual says:

DateStyle (string)
Sets the display format for date and time values, as well as the rules for 
interpreting ambiguous date input values. For historical reasons, this 
variable contains two independent components: the output format 
specification (ISO, Postgres, SQL, or German) and the input/output 
specification for year/month/day ordering (DMY, MDY, or YMD). ...



And says:

http://www.postgresql.org/docs/current/static/datatype-datetime.html

8.5.2. Date/Time Output
The output of the date and time types is of course only the date or time 
part in accordance with the given examples.



After doing "SET datestyle = 'Postgres, MDY'" on the psql prompt, I did the 
following things on the same psql session:



1. SELECT current_timestamp;

  now
--
Wed Jul 24 10:51:00.217 2013 GMT
(1 行)

This is exactly as I expected.


2. SELECT current_date;
I expected the output "Wed Jul 24 2013" or "Jul 24 2013", but I got:

   date

07-24-2013
(1 行)

This does not follow the above statement in 8.5.2.  This output is created 
by EncodeDateOnly() in src/backend/utils/adt/datetime.c.



Regards
MauMau



--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers