Re: BUG #9265: why the same interval can't get the same timestamp? - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #9265: why the same interval can't get the same timestamp?
Date
Msg-id 23717.1392733577@sss.pgh.pa.us
Whole thread Raw
In response to BUG #9265: why the same interval can't get the same timestamp?  (miaoyimin@huawei.com)
List pgsql-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

pgsql-bugs by date:

Previous
From: Vik Fearing
Date:
Subject: Re: BUG #9265: why the same interval can't get the same timestamp?
Next
From: Francisco Olarte
Date:
Subject: Re: BUG #9265: why the same interval can't get the same timestamp?