From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Domain based on TIMEZONE WITH TIME ZONE
Date: Sun, 13 May 2018 17:55:52 -0700
Message-ID: <db2cab0f-9344-ad07-8fc7-c3c6e09f4a03@aklaver.com> (raw)
In-Reply-To: <20180513224507.mlbdgz54mygxrdpu@hjp.at>
References: <CA+bJJbz0Gwo8mkyzHa_4qjcNcMV0M00yTZ_LjUtaJu=M=+bpyQ@mail.gmail.com>
<188A0270-0A9A-4ADE-A928-9067E99AE7B7@relops.com>
<CA+bJJbyNTns-AMVUbztjb+zeNZ-z0gH=6vXykZCmjCJiK1GogA@mail.gmail.com>
<D03AF820-9FFF-414F-8747-B3589FBB9224@relops.com>
<CA+bJJbw96Ndugh11T9WWdGzUL+Cm6=CGxChi=4yfxSO7dnneJQ@mail.gmail.com>
<2fcedf5b-cac6-40a9-dc83-c3b6833e3a49@aklaver.com>
<CA+bJJbxTV5yHiNHOdK3zUzBkjgL94NXGgv-6Zk-m=7Xus9ovAw@mail.gmail.com>
<41e645b1-4a65-48f3-07ab-4ecb63e3481c@aklaver.com>
<CA+bJJbz13SCVR-fih5UObFMf_yy-R=SkCD8dJ-Vk-0wAmecRWQ@mail.gmail.com>
<2dc9720b-d516-d53b-e44b-b3d2ec0aa14c@aklaver.com>
<20180513224507.mlbdgz54mygxrdpu@hjp.at>
On 05/13/2018 03:45 PM, Peter J. Holzer wrote:
> On 2018-05-13 12:46:42 -0700, Adrian Klaver wrote:
>> Not trying to trick anyone and no magic. The difference in the represented
>> values between ts_tz and ts_naive is the heart of my argument. Timestamptz
>> values are stored in manner that allows you to have the output with a time
>> zone offset. Timestamps w/notz are not.
>
> I disagree. The difference isn't in how they are *stored*. We have
> already established that they are stored in the same format.
>
> The difference is in their *semantics*.
Exactly, timestamptz allows you to retrieve an unambiguous point in
time, timestamp does not. We could argue all day about the details, but
the previous sentence is the important distinction.
>
> A timestamptz denotes a unique and unambiguous point in time. This point
> in time can be represented in various time zones. So the point in time
> when Apollo 11 launched can be represented as '1969-07-16 09:32:00-04'
> (local time) or '1969-07-16 13:32:00+00' (UTC) or '1969-07-16
> 14:32:00+01' (CET). These are just different ways to denote the same
> point in time - and in fact all three are stored as the same timestamptz
> value (-14552880000000, I think). Only when displaying the value or
> doing certain operations on it is it converted to YMDhmsfz format.
>
> A timestamp without timezone does NOT denote an unambiguous point in
> time. It is just a compact form of representing a date and time. But
> without any additional context (the location or time zone) this doesn't
> tell you much. '2018-01-01 00:00' in Kiribati was 25 hours before
> '2018-01-01 00:00' in American Samoa.
>
>
>>> But timestamps do not have timezone. They are points in the time line.
>>> Points in earth surface have timezones, countries have timezones, but
>>> nor timestamp.
>>
>> I don't know about you but I am living on the earths surface:). That means
>> when I deal with timestamps they are with reference to a location.
>
> But when you store a timestamp as a timestamptz, you lose that reference
> to a location. All that is left is an abstract reference to a point in
> time. Only when you read that value again (and do certain operations
A point in time anchored to location, the prime meridian. Now I agree
you lose the original location information, but for many operations that
is not important as you can reconstitute any location at a later date.
For those operations where it is important, ideas have been floated on
this list for dealing with this. I remember a proposal for a composite
type that included the timestamp and the original timezone. That became
an actual extension(?) at some point, but I cannot dig it up at the moment.
> with it) is that reference to a location added again - but the current
> location of the reader, not the the original locaton (that is lost
> forever, unless it was stored elsewhere).
>
>
>> I will agree that timestamptz is stored as number only. However that number
>> in Postgres has an implied time zone of UTC:
>>
>> https://www.postgresql.org/docs/10/static/datatype-datetime.html#DATATYPE-DATETIME-INPUT
>>
>> "For timestamp with time zone, the internally stored value is always in UTC
>> (Universal Coordinated Time, traditionally known as Greenwich Mean Time,
>> GMT)"
>
> This is not actually true. There is nothing in the storage format which
> depends on UTC (well, the epoch is at Midnight UTC, at if you say the
Agreed it is a stored number. What makes timestamptz work is that the
number is relative to Midnight UTC and that the Postgres datetime code
knows this and uses that knowledge to create unambiguous points in time.
If you where to throw that number at some other program without any
context then you would be dealing with just a number. The point is that
it is being dealt with inside Postgres from a known point of reference
and so the stored number is more then just a number.
> epoch is at 08:00 Beijing time it is equally correct).
>
> hp
>
--
Adrian Klaver
adrian.klaver@aklaver.com
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-general@postgresql.org
Cc: adrian.klaver@aklaver.com, hjp-pgsql@hjp.at
Subject: Re: Domain based on TIMEZONE WITH TIME ZONE
In-Reply-To: <db2cab0f-9344-ad07-8fc7-c3c6e09f4a03@aklaver.com>
References: <CA+bJJbz0Gwo8mkyzHa_4qjcNcMV0M00yTZ_LjUtaJu=M=+bpyQ@mail.gmail.com> <188A0270-0A9A-4ADE-A928-9067E99AE7B7@relops.com> <CA+bJJbyNTns-AMVUbztjb+zeNZ-z0gH=6vXykZCmjCJiK1GogA@mail.gmail.com> <D03AF820-9FFF-414F-8747-B3589FBB9224@relops.com> <CA+bJJbw96Ndugh11T9WWdGzUL+Cm6=CGxChi=4yfxSO7dnneJQ@mail.gmail.com> <2fcedf5b-cac6-40a9-dc83-c3b6833e3a49@aklaver.com> <CA+bJJbxTV5yHiNHOdK3zUzBkjgL94NXGgv-6Zk-m=7Xus9ovAw@mail.gmail.com> <41e645b1-4a65-48f3-07ab-4ecb63e3481c@aklaver.com> <CA+bJJbz13SCVR-fih5UObFMf_yy-R=SkCD8dJ-Vk-0wAmecRWQ@mail.gmail.com> <2dc9720b-d516-d53b-e44b-b3d2ec0aa14c@aklaver.com> <20180513224507.mlbdgz54mygxrdpu@hjp.at> <db2cab0f-9344-ad07-8fc7-c3c6e09f4a03@aklaver.com>
* 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