public inbox for [email protected]  
help / color / mirror / Atom feed
From: Bruce Momjian <[email protected]>
To: Tom Lane <[email protected]>
Cc: PostgreSQL-documentation <[email protected]>
Subject: Re: AT TIME ZONE correction
Date: Sat, 1 Sep 2018 23:28:21 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>

On Sat, Sep  1, 2018 at 07:37:36PM -0400, Bruce Momjian wrote:
> > Here we've got a time value that was initially given in EST (-05),
> > but was converted to UTC by timestampz_in.  Then the AT TIME ZONE
> > says "Please convert this UTC value to MST, and emit it as a zoneless
> > timestamp" (which will not be subject to any further conversion when
> > it's displayed).
> > 
> > The existing text is indeed a bit deficient, because it fails to
> > draw a clear boundary between what the AT TIME ZONE operator is
> > doing and what is being done by the timestamp(tz) I/O functions.
> > But you're not making it better.
> 
> Yes, I am still researching and realize my diff is wrong.  Let me keep
> working and I will repost.

I have developed the attached patch, which I think is an improvement.

-- 
  Bruce Momjian  <[email protected]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +


Attachments:

  [text/x-diff] time_zone.diff (2.2K, 2-time_zone.diff)
  download | inline diff:
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
new file mode 100644
index bb794e0..53aa515
*** a/doc/src/sgml/func.sgml
--- b/doc/src/sgml/func.sgml
*************** SELECT date_trunc('year', TIMESTAMP '200
*** 8082,8089 ****
     </indexterm>
  
     <para>
!     The <literal>AT TIME ZONE</literal> construct allows conversions
!     of time stamps to different time zones.  <xref
      linkend="functions-datetime-zoneconvert-table"/> shows its
      variants.
     </para>
--- 8082,8089 ----
     </indexterm>
  
     <para>
!     The <literal>AT TIME ZONE</literal> construct allows the addition,
!     conversion, and removal of time zones for time stamp values.  <xref
      linkend="functions-datetime-zoneconvert-table"/> shows its
      variants.
     </para>
*************** SELECT TIMESTAMP '2001-02-16 20:38:40' A
*** 8145,8153 ****
  SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST';
  <lineannotation>Result: </lineannotation><computeroutput>2001-02-16 18:38:40</computeroutput>
  </screen>
!     The first example takes a time stamp without time zone and interprets it as MST time
!     (UTC-7), which is then converted to PST (UTC-8) for display.  The second example takes
!     a time stamp specified in EST (UTC-5) and converts it to local time in MST (UTC-7).
     </para>
  
     <para>
--- 8145,8159 ----
  SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST';
  <lineannotation>Result: </lineannotation><computeroutput>2001-02-16 18:38:40</computeroutput>
  </screen>
!     The first example takes a time stamp without time zone and interprets
!     it in the MST time zone (UTC-7), returning a time stamp with time
!     zone value which is displayed in local time (PST, UTC-8).  The second
!     example takes a time stamp with time zone value (EST, UTC-5) and
!     converts it to the date and time in MST (UTC-7) without time zone.
!     Basically, the first example takes the date and time and puts it in
!     the specified time zone.  The second example takes a time stamp with
!     time zone and shifts it to the specified time zone. (No time zone
!     designation is returned.)
     </para>
  
     <para>


view thread (8+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: AT TIME ZONE correction
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox