Lists: | pgsql-hackers |
---|
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Why not ISO 8601 format for date values rendered into JSON? |
Date: | 2014-08-18 00:42:11 |
Message-ID: | 12707.1408322531@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
I was just going over the release notes, and noticed the bit about
timestamp and timestamptz now being rendered in a fixed ISO-8601-compliant
format rather than whatever random DateStyle is in use. That's fine,
but I wonder why the same approach wasn't applied to type date?
regression=# set datestyle to postgres;
SET
regression=# select row_to_json(row(now()));
row_to_json
-------------------------------------------
{"f1":"2014-08-17T20:34:54.424237-04:00"}
(1 row)
regression=# select row_to_json(row(current_date));
row_to_json
---------------------
{"f1":"08-17-2014"}
(1 row)
Doesn't seem real consistent ...
regards, tom lane
From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: Why not ISO 8601 format for date values rendered into JSON? |
Date: | 2014-08-18 01:50:01 |
Message-ID: | 53F15BC9.2010307@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 08/17/2014 08:42 PM, Tom Lane wrote:
> I was just going over the release notes, and noticed the bit about
> timestamp and timestamptz now being rendered in a fixed ISO-8601-compliant
> format rather than whatever random DateStyle is in use. That's fine,
> but I wonder why the same approach wasn't applied to type date?
>
> regression=# set datestyle to postgres;
> SET
>
> regression=# select row_to_json(row(now()));
> row_to_json
> -------------------------------------------
> {"f1":"2014-08-17T20:34:54.424237-04:00"}
> (1 row)
>
> regression=# select row_to_json(row(current_date));
> row_to_json
> ---------------------
> {"f1":"08-17-2014"}
> (1 row)
>
> Doesn't seem real consistent ...
>
>
Good point. Probably because I didn't get a complaint about it, which in
turn is probably because JavaScript's builtin Date class is in fact
(from our POV) more or less a timestamp(tz) type.
See
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date>
But yes, I agree it should be fixed. Whatever we output should be
suitable as input for the string-argument constructor of class Date.
cheers
andrew
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: Why not ISO 8601 format for date values rendered into JSON? |
Date: | 2014-08-18 01:53:08 |
Message-ID: | 14119.1408326788@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> On 08/17/2014 08:42 PM, Tom Lane wrote:
>> I was just going over the release notes, and noticed the bit about
>> timestamp and timestamptz now being rendered in a fixed ISO-8601-compliant
>> format rather than whatever random DateStyle is in use. That's fine,
>> but I wonder why the same approach wasn't applied to type date?
> But yes, I agree it should be fixed. Whatever we output should be
> suitable as input for the string-argument constructor of class Date.
OK. I think I can fix it, if you don't have time.
regards, tom lane
From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: Why not ISO 8601 format for date values rendered into JSON? |
Date: | 2014-08-18 02:50:34 |
Message-ID: | 53F169FA.3040606@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 08/17/2014 09:53 PM, Tom Lane wrote:
>
> OK. I think I can fix it, if you don't have time.
>
>
[offlist]
Thanks. FYI I am still recovering from treatment for prostate cancer I
had not long after pgcon ... it's taken more out of me that I expected,
so time is limited.
cheers
andrew
From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: Why not ISO 8601 format for date values rendered into JSON? |
Date: | 2014-08-18 02:53:11 |
Message-ID: | 53F16A97.3020703@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 08/17/2014 10:50 PM, Andrew Dunstan wrote:
>
> On 08/17/2014 09:53 PM, Tom Lane wrote:
>>
>> OK. I think I can fix it, if you don't have time.
>>
>>
>
>
> [offlist]
>
> Thanks. FYI I am still recovering from treatment for prostate cancer I
> had not long after pgcon ... it's taken more out of me that I
> expected, so time is limited.
>
>
Darn it. well, I guess everyone knows now. *sigh*
cheers
andrew