Re: [DOCS] Add example about date ISO format

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, juha(dot)mustonen(at)iki(dot)fi, pgsql-docs(at)postgresql(dot)org
Subject: Re: [DOCS] Add example about date ISO format
Date: 2023-11-22 13:02:02
Message-ID: ijnhw7ykfvzllqtqgwwm5vboz4ovfaxwxk3xhmgpzc62nbth6a@wvqdpbjzjxly
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On 2023-11-22 10:14 +0100, Laurenz Albe wrote:
> On Tue, 2023-11-21 at 23:33 -0500, Bruce Momjian wrote:
> > On Fri, Feb 17, 2017 at 04:01:54PM +0000, juha(dot)mustonen(at)iki(dot)fi wrote:
> > > The following documentation comment has been logged on the website:
> > >
> > > Page: https://www.postgresql.org/docs/9.6/static/functions-formatting.html
> > > Description:
> > >
> > > The documentation should include an example how to format datetime entry
> > > into most commonly known ISO format. This is a bit tricky as literal
> > > character needs to included with quotes:
> > >
> > > to_char(NOW(), &#39;YYYY-MM-DD&quot;T&quot;HH24:MI:SSZ&#39;)
> >
> > I know this is a six-year-old idea, but it is still a good one. I have
> > developed the attached patch I would like to apply to master.
> >
> > diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
> > index 93f068edcf..297cafb341 100644
> > --- a/doc/src/sgml/func.sgml
> > +++ b/doc/src/sgml/func.sgml
> > @@ -8489,6 +8489,14 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
> > </para>
> > </listitem>
> >
> > + <listitem>
> > + <para>
> > + <literal>to_char(current_timestamp AT TIME ZONE 'UTC',
> > + 'YYYY-MM-DD"T"HH24:MI:SSZ')</literal> outputs the current UTC

This might be excessive, but should we have an example with other time
zones? ISO 8601 is not limited to UTC. For example:
YYYY-MM-DD"T"HH24:MI:SSOF or YYYY-MM-DD"T"HH24:MI:SSTZH:TZM

Fractional seconds are also possible: YYYY-MM-DD"T"HH24:MI:SS,FF6

> > + date/time in <acronym>ISO</acronym> 8601 date/time format.
> > + </para>
> > + </listitem>
> > +
> > </itemizedlist>
> > </para>
> >
>
> +1 on the idea, but from the context it looks like you added that example
> at the regular expression matching functions.
>
> I think the example had best be at "8.5.2. Date/Time Output", in
> doc/src/sgml/datatype.sgml around line 2552.

+1 for moving it to section 8.5.2.

--
Erik

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Bruce Momjian 2023-11-22 16:58:38 Re: [DOCS] Add example about date ISO format
Previous Message Laurenz Albe 2023-11-22 09:31:25 Re: [DOCS] Confusing Trigger Docs.