pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: miaoyimin@huawei.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #9265: why the same interval can't get the same timestamp?
Date: Tue, 18 Feb 2014 09:26:17 -0500
Message-ID: <23717.1392733577@sss.pgh.pa.us> (raw)
In-Reply-To: <20140218120621.24620.15178@wrigleys.postgresql.org>
References: <20140218120621.24620.15178@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

miaoyimin@huawei.com writes:
> postgres=# select ('epoch'::pg_catalog.timestamptz + 1386201600 * '1
> second'::pg_catalog.interval);
>         ?column?
> ------------------------
>  2013-12-05 08:00:00+08
> (1 row)

> postgres=# select ('epoch'::pg_catalog.timestamptz + 16044 * '1
> day'::pg_catalog.interval);
>         ?column?
> ------------------------
>  2013-12-05 07:30:00+08
> (1 row)

It's intentional that those don't give the same result.  Adding days
is DST-aware, adding seconds is not.  Since the epoch in that zone
was

# select 'epoch'::pg_catalog.timestamptz;
        timestamptz        
---------------------------
 1970-01-01 07:30:00+07:30
(1 row)

adding any number of days to it will produce 07:30 local time on
the selected day, even though the zone offset changes.

			regards, tom lane


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



view thread (4+ messages)  latest in thread

Message-ID: <23717.1392733577@sss.pgh.pa.us>
Permalink:  ../23717.1392733577@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23717.1392733577@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, miaoyimin@huawei.com
  Subject: Re: BUG #9265: why the same interval can't get the same timestamp?
  In-Reply-To: <23717.1392733577@sss.pgh.pa.us>
  References: <20140218120621.24620.15178@wrigleys.postgresql.org> <23717.1392733577@sss.pgh.pa.us>

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

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