Re: timetz need more bytes than timestamptz

From: Junwang Zhao <zhjwpku(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: timetz need more bytes than timestamptz
Date: 2023-06-19 05:20:22
Message-ID: CAEG8a3KOQqdJX8Zn4mszh=pvt2nYpgS1e73+zROV_COJ+q0Yrw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

timetz stores only the time units within a day, it uses an extra field
to store the zone info.

typedef int64 TimeADT;
typedef struct
{
TimeADT time; /* all time units other than months and years */
int32 zone; /* numeric time zone, in seconds */
} TimeTzADT;

timestamp is a count that starts on January 1st, 1970 at UTC.

You can convert a timestamp to any timezone, but not timetz.

On Mon, Jun 19, 2023 at 11:53 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
>
> Hi,
> https://www.postgresql.org/docs/current/datatype-datetime.html
> timetz, timestamptz:
> same resolution.
> fractional digits in the seconds field are also the same.
> >
> > All timezone-aware dates and times are stored internally in UTC. They are converted to local time in the zone specified by the TimeZone configuration parameter before being displayed to the client.
>
> Why does timetz need more bytes (8 vs 12) than timestamptz?

--
Regards
Junwang Zhao

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Wen Yi 2023-06-19 07:28:50 [Beginner Question]How to let the lex && yacc parsing the string? Instead of the console.
Previous Message Thomas Markus 2023-06-19 04:06:33 Re: Question: Multiple pg clusters on one server can be reached with the standard port.